diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index a55afddb..f70e6fbf 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -59,6 +59,19 @@ // Unless documented elsewhere these configuration macros should be considered // an implementation detail, I'll try not to break them, but you never know. +// Use Sun C++ workarounds +// I'm not sure which versions of the compiler require these workarounds, so +// I'm just using them of everything older than the current test compilers +// (as of May 2017). + +#if !defined(BOOST_UNORDERED_SUN_WORKAROUNDS1) +#if BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0) +#define BOOST_UNORDERED_SUN_WORKAROUNDS1 1 +#else +#define BOOST_UNORDERED_SUN_WORKAROUNDS1 0 +#endif +#endif + // BOOST_UNORDERED_EMPLACE_LIMIT = The maximum number of parameters in // emplace (not including things like hints). Don't set it to a lower value, as // that might break something. @@ -100,7 +113,7 @@ // I had problems with tuples on older versions of the sunpro. // Might be fixed in an earlier version than I specified here. -#elif BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0) +#elif BOOST_UNORDERED_SUN_WORKAROUNDS1 #define BOOST_UNORDERED_TUPLE_ARGS 0 // Assume if we have C++11 tuple it's properly variadic, @@ -270,7 +283,7 @@ template struct prime_list_template { static std::size_t const value[]; -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 static std::ptrdiff_t const length; #else static std::ptrdiff_t const length = @@ -282,7 +295,7 @@ template std::size_t const prime_list_template::value[] = { BOOST_PP_SEQ_ENUM(BOOST_UNORDERED_PRIMES)}; -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 template std::ptrdiff_t const prime_list_template::length = BOOST_PP_SEQ_SIZE( BOOST_UNORDERED_PRIMES); @@ -1336,7 +1349,7 @@ inline void construct_value(T* address, BOOST_FWD_REF(A0) a0) // // Used to emulate piecewise construction. -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 #define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(z, n, namespace_) \ template struct length { diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 25c731ec..c8bd5bb4 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -230,7 +230,7 @@ template class unordered_map #else -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 // 0 argument emplace requires special treatment in case // the container is instantiated with a value type that @@ -292,7 +292,7 @@ template class unordered_map #else -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 iterator emplace_hint(const_iterator hint, boost::unordered::detail::empty_emplace = @@ -1031,7 +1031,7 @@ template class unordered_multimap #else -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 // 0 argument emplace requires special treatment in case // the container is instantiated with a value type that @@ -1091,7 +1091,7 @@ template class unordered_multimap #else -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 iterator emplace_hint(const_iterator hint, boost::unordered::detail::empty_emplace = diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 80137565..f2be1176 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -228,7 +228,7 @@ template class unordered_set #else -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 // 0 argument emplace requires special treatment in case // the container is instantiated with a value type that @@ -290,7 +290,7 @@ template class unordered_set #else -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 iterator emplace_hint(const_iterator hint, boost::unordered::detail::empty_emplace = @@ -737,7 +737,7 @@ template class unordered_multiset #else -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 // 0 argument emplace requires special treatment in case // the container is instantiated with a value type that @@ -797,7 +797,7 @@ template class unordered_multiset #else -#if !(BOOST_COMP_SUNPRO && BOOST_COMP_SUNPRO < BOOST_VERSION_NUMBER(5, 21, 0)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 iterator emplace_hint(const_iterator hint, boost::unordered::detail::empty_emplace = diff --git a/test/unordered/insert_tests.cpp b/test/unordered/insert_tests.cpp index 26141d0e..3f68d316 100644 --- a/test/unordered/insert_tests.cpp +++ b/test/unordered/insert_tests.cpp @@ -530,7 +530,7 @@ template void move_emplace_tests(X*, test::random_generator generator) template void default_emplace_tests(X*, test::random_generator) { -#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 bool is_unique = test::has_unique_keys::value; X x; @@ -1108,7 +1108,7 @@ UNORDERED_AUTO_TEST(map_emplace_test) test::allocator1 > > x; -#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 x.emplace(); BOOST_TEST(x.find(0) != x.end() && x.find(0)->second == overloaded_constructor()); @@ -1129,7 +1129,7 @@ UNORDERED_AUTO_TEST(map_emplace_test) test::allocator1 > > x; -#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 x.emplace(); BOOST_TEST(x.find(0) != x.end() && x.find(0)->second == overloaded_constructor()); @@ -1146,7 +1146,7 @@ UNORDERED_AUTO_TEST(set_emplace_test) boost::unordered_set x; overloaded_constructor check; -#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 x.emplace(); BOOST_TEST(x.find(check) != x.end() && *x.find(check) == check); #endif diff --git a/test/unordered/unnecessary_copy_tests.cpp b/test/unordered/unnecessary_copy_tests.cpp index 0322eade..1e22dd66 100644 --- a/test/unordered/unnecessary_copy_tests.cpp +++ b/test/unordered/unnecessary_copy_tests.cpp @@ -362,7 +362,7 @@ UNORDERED_AUTO_TEST(unnecessary_copy_emplace_set_test) // 0 arguments // -#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 // The container will have to create a copy in order to compare with // the existing element. reset(); @@ -451,7 +451,7 @@ UNORDERED_AUTO_TEST(unnecessary_copy_emplace_map_test) // 0 arguments // -#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 // COPY_COUNT(1) would be okay here. reset(); x.emplace();