From 20c93605288ad8f89e2416416f54b78839f75326 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 20 May 2009 06:43:38 +0000 Subject: [PATCH] Better configuration for boost.unordered. [SVN r53127] --- include/boost/unordered/detail/config.hpp | 8 ++++++++ include/boost/unordered/detail/hash_table.hpp | 3 ++- include/boost/unordered/detail/hash_table_impl.hpp | 8 ++++---- include/boost/unordered/unordered_map.hpp | 12 ++++++++---- include/boost/unordered/unordered_set.hpp | 12 ++++++++---- test/objects/exception.hpp | 2 +- test/objects/minimal.hpp | 2 +- test/objects/test.hpp | 2 +- 8 files changed, 33 insertions(+), 16 deletions(-) diff --git a/include/boost/unordered/detail/config.hpp b/include/boost/unordered/detail/config.hpp index f277feae..68c9875a 100644 --- a/include/boost/unordered/detail/config.hpp +++ b/include/boost/unordered/detail/config.hpp @@ -19,4 +19,12 @@ # define BOOST_UNORDERED_NO_HAS_MOVE_ASSIGN #endif +#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +# if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) + // STLport doesn't have std::forward. +# else +# define BOOST_UNORDERED_STD_FORWARD +# endif +#endif + #endif diff --git a/include/boost/unordered/detail/hash_table.hpp b/include/boost/unordered/detail/hash_table.hpp index bb4072c6..8a458f7f 100644 --- a/include/boost/unordered/detail/hash_table.hpp +++ b/include/boost/unordered/detail/hash_table.hpp @@ -12,6 +12,7 @@ #endif #include +#include #if !defined(BOOST_UNORDERED_EMPLACE_LIMIT) #define BOOST_UNORDERED_EMPLACE_LIMIT 5 @@ -45,7 +46,7 @@ #include -#if !(defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL)) +#if !(defined(BOOST_UNORDERED_STD_FORWARD)) #include #include diff --git a/include/boost/unordered/detail/hash_table_impl.hpp b/include/boost/unordered/detail/hash_table_impl.hpp index 81327302..bc842dc8 100644 --- a/include/boost/unordered/detail/hash_table_impl.hpp +++ b/include/boost/unordered/detail/hash_table_impl.hpp @@ -198,7 +198,7 @@ namespace boost { } } -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) template void construct(Args&&... args) { @@ -1602,7 +1602,7 @@ namespace boost { // For maps if there is more than one argument, the key can be the first argument. -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) template static BOOST_DEDUCED_TYPENAME boost::mpl::if_< @@ -1733,7 +1733,7 @@ namespace boost { #if BOOST_UNORDERED_EQUIVALENT_KEYS -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) // Emplace (equivalent key containers) // (I'm using an overloaded emplace for both 'insert' and 'emplace') @@ -1943,7 +1943,7 @@ namespace boost { } } -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) // Emplace (unique keys) // (I'm using an overloaded emplace for both 'insert' and 'emplace') diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index a7ebd691..5a282879 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -21,6 +21,10 @@ #include #endif +#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#include +#endif + #if defined(BOOST_MSVC) #pragma warning(push) #if BOOST_MSVC >= 1400 @@ -135,7 +139,7 @@ namespace boost #endif #endif -#if !defined(BOOST_NO_INITIALIZER_LISTS) +#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) unordered_map(std::initializer_list list, size_type n = boost::unordered_detail::default_initial_bucket_count, const hasher &hf = hasher(), @@ -219,7 +223,7 @@ namespace boost // modifiers -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) template std::pair emplace(Args&&... args) { @@ -585,7 +589,7 @@ namespace boost #endif #endif -#if !defined(BOOST_NO_INITIALIZER_LISTS) +#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) unordered_multimap(std::initializer_list list, size_type n = boost::unordered_detail::default_initial_bucket_count, const hasher &hf = hasher(), @@ -670,7 +674,7 @@ namespace boost // modifiers -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) template iterator emplace(Args&&... args) { diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index f39a76df..cfe6c9b7 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -21,6 +21,10 @@ #include #endif +#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#include +#endif + #if defined(BOOST_MSVC) #pragma warning(push) #if BOOST_MSVC >= 1400 @@ -133,7 +137,7 @@ namespace boost #endif #endif -#if !defined(BOOST_NO_INITIALIZER_LISTS) +#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) unordered_set(std::initializer_list list, size_type n = boost::unordered_detail::default_initial_bucket_count, const hasher &hf = hasher(), @@ -217,7 +221,7 @@ namespace boost // modifiers -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) template std::pair emplace(Args&&... args) { @@ -555,7 +559,7 @@ namespace boost #endif #endif -#if !defined(BOOST_NO_INITIALIZER_LISTS) +#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) unordered_multiset(std::initializer_list list, size_type n = boost::unordered_detail::default_initial_bucket_count, const hasher &hf = hasher(), @@ -639,7 +643,7 @@ namespace boost // modifiers -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) template iterator emplace(Args&&... args) { diff --git a/test/objects/exception.hpp b/test/objects/exception.hpp index 25f783ec..22119e85 100644 --- a/test/objects/exception.hpp +++ b/test/objects/exception.hpp @@ -347,7 +347,7 @@ namespace exception detail::tracker.track_construct((void*) p, sizeof(T), tag_); } -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) template void construct(pointer p, Args&&... args) { UNORDERED_SCOPE(allocator::construct(pointer, Args&&...)) { UNORDERED_EPOINT("Mock allocator construct function."); diff --git a/test/objects/minimal.hpp b/test/objects/minimal.hpp index 535a7684..252e3564 100644 --- a/test/objects/minimal.hpp +++ b/test/objects/minimal.hpp @@ -229,7 +229,7 @@ namespace minimal void construct(pointer p, T const& t) { new((void*)p.ptr_) T(t); } -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) template void construct(pointer p, Args&&... args) { new((void*)p.ptr_) T(std::forward(args)...); } diff --git a/test/objects/test.hpp b/test/objects/test.hpp index 28fc5e53..63f7c91b 100644 --- a/test/objects/test.hpp +++ b/test/objects/test.hpp @@ -218,7 +218,7 @@ namespace test new(p) T(t); } -#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL) +#if defined(BOOST_UNORDERED_STD_FORWARD) template void construct(pointer p, Args&&... args) { detail::tracker.track_construct((void*) p, sizeof(T), tag_); new(p) T(std::forward(args)...);