Avoid using 'boost::aligned_storage' which is known to be problematic in MSVC builds:-

https://www.boost.org/doc/libs/1_65_0/libs/type_traits/doc/html/boost_typetraits/reference/aligned_storage.html
This commit is contained in:
John Emmas 2020-03-10 12:28:52 +00:00
parent 9ef5f4d159
commit 4e137d5cbb
2 changed files with 22 additions and 1 deletions

View file

@ -104,8 +104,19 @@ public:
*/
bool is_subset (const ChanMapping& superset) const;
#if defined(_MSC_VER) && (_MSC_VER < 1900)
/* Use the older (heap based) mapping for early versions of MSVC.
* In fact it might be safer to use this for all MSVC builds - as
* our StackAllocator class depends on 'boost::aligned_storage'
* which is known to be troublesome with Visual C++ :-
* https://www.boost.org/doc/libs/1_65_0/libs/type_traits/doc/html/boost_typetraits/reference/aligned_storage.html
*/
typedef std::map<uint32_t, uint32_t> TypeMapping;
typedef std::map<DataType, TypeMapping> Mappings;
#else
typedef std::map<uint32_t, uint32_t, std::less<uint32_t>, PBD::StackAllocator<std::pair<const uint32_t, uint32_t>, 16> > TypeMapping;
typedef std::map<DataType, TypeMapping, std::less<DataType>, PBD::StackAllocator<std::pair<const DataType, TypeMapping>, 2> > Mappings;
#endif
Mappings mappings() { return _mappings; }
const Mappings& mappings() const { return _mappings; }

View file

@ -371,7 +371,17 @@ private:
/* ordered map [plugin instance ID] => ARDOUR::ChanMapping
* TODO: consider replacing with boost::flat_map<> or std::vector<>.
*/
class PinMappings : public std::map <uint32_t, ARDOUR::ChanMapping, std::less<uint32_t>, PBD::StackAllocator<std::pair<const uint32_t, ARDOUR::ChanMapping>, 4> >
#if defined(_MSC_VER) && (_MSC_VER < 1900)
/* Use the older (heap based) mapping for early versions of MSVC.
* In fact it might be safer to use this for all MSVC builds - as
* our StackAllocator class depends on 'boost::aligned_storage'
* which is known to be troublesome with Visual C++ :-
* https://www.boost.org/doc/libs/1_65_0/libs/type_traits/doc/html/boost_typetraits/reference/aligned_storage.html
*/
class PinMappings : public std::map <uint32_t, ARDOUR::ChanMapping>
#else
class PinMappings : public std::map <uint32_t, ARDOUR::ChanMapping, std::less<uint32_t>, PBD::StackAllocator<std::pair<const uint32_t, ARDOUR::ChanMapping>, 4> >
#endif
{
public:
/* this emulates C++11's std::map::at()