diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index d45ca246..9914683f 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -35,12 +35,11 @@ #include #include #include -#include #include #include #include +#include #include -#include #include #include #include @@ -740,19 +739,6 @@ namespace boost { #pragma warning(pop) #endif - //////////////////////////////////////////////////////////////////////////// - // is_nothrow_swappable - // - // TODO: Replace this very basic implementation when the full type_traits - // implementation is available. - - template - struct is_nothrow_swappable - : boost::integral_constant::value && !boost::is_const::value> - { - }; - ////////////////////////////////////////////////////////////////////////// // value_base // @@ -1800,7 +1786,7 @@ namespace boost { BOOST_FWD_REF(A0), BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) { boost::unordered::detail::func::construct_from_tuple( - alloc, boost::addressof (address->first), boost::forward(a1)); + alloc, boost::addressof(address->first), boost::forward(a1)); BOOST_TRY { boost::unordered::detail::func::construct_from_tuple( @@ -1997,7 +1983,7 @@ namespace boost { { BOOST_ASSERT(!node_); node_ = node_allocator_traits::allocate(alloc_, 1); - new ((void*) boost::to_address(node_)) node(); + new ((void*)boost::to_address(node_)) node(); } template struct node_tmp @@ -2756,8 +2742,8 @@ namespace boost { boost::is_nothrow_move_constructible::value && boost::is_nothrow_move_constructible

::value; static const bool nothrow_swappable = - boost::unordered::detail::is_nothrow_swappable::value && - boost::unordered::detail::is_nothrow_swappable

::value; + boost::is_nothrow_swappable::value && + boost::is_nothrow_swappable

::value; private: functions& operator=(functions const&); @@ -3220,9 +3206,9 @@ namespace boost { bucket_pointer end = buckets_ + static_cast(new_count); for (bucket_pointer i = buckets_; i != end; ++i) { - new ((void*) boost::to_address(i)) bucket(); + new ((void*)boost::to_address(i)) bucket(); } - new ((void*) boost::to_address(end)) bucket(dummy_node); + new ((void*)boost::to_address(end)) bucket(dummy_node); } //////////////////////////////////////////////////////////////////////// diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index acaf99c6..1910219c 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -717,8 +717,8 @@ namespace boost { void swap(unordered_map&) BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&& - boost::unordered::detail::is_nothrow_swappable::value&& - boost::unordered::detail::is_nothrow_swappable

::value); + boost::is_nothrow_swappable::value&& + boost::is_nothrow_swappable

::value); void clear() BOOST_NOEXCEPT { table_.clear_impl(); } template @@ -1326,8 +1326,8 @@ namespace boost { void swap(unordered_multimap&) BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&& - boost::unordered::detail::is_nothrow_swappable::value&& - boost::unordered::detail::is_nothrow_swappable

::value); + boost::is_nothrow_swappable::value&& + boost::is_nothrow_swappable

::value); void clear() BOOST_NOEXCEPT { table_.clear_impl(); } template @@ -1737,8 +1737,8 @@ namespace boost { template void unordered_map::swap(unordered_map& other) BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&& - boost::unordered::detail::is_nothrow_swappable::value&& - boost::unordered::detail::is_nothrow_swappable

::value) + boost::is_nothrow_swappable::value&& + boost::is_nothrow_swappable

::value) { table_.swap(other.table_); } @@ -2213,8 +2213,8 @@ namespace boost { template void unordered_multimap::swap(unordered_multimap& other) BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&& - boost::unordered::detail::is_nothrow_swappable::value&& - boost::unordered::detail::is_nothrow_swappable

::value) + boost::is_nothrow_swappable::value&& + boost::is_nothrow_swappable

::value) { table_.swap(other.table_); } diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 92af2c01..dfc24e85 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -443,8 +443,8 @@ namespace boost { void swap(unordered_set&) BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&& - boost::unordered::detail::is_nothrow_swappable::value&& - boost::unordered::detail::is_nothrow_swappable

::value); + boost::is_nothrow_swappable::value&& + boost::is_nothrow_swappable

::value); void clear() BOOST_NOEXCEPT { table_.clear_impl(); } template @@ -990,8 +990,8 @@ namespace boost { void swap(unordered_multiset&) BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&& - boost::unordered::detail::is_nothrow_swappable::value&& - boost::unordered::detail::is_nothrow_swappable

::value); + boost::is_nothrow_swappable::value&& + boost::is_nothrow_swappable

::value); void clear() BOOST_NOEXCEPT { table_.clear_impl(); } template @@ -1362,8 +1362,8 @@ namespace boost { template void unordered_set::swap(unordered_set& other) BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&& - boost::unordered::detail::is_nothrow_swappable::value&& - boost::unordered::detail::is_nothrow_swappable

::value) + boost::is_nothrow_swappable::value&& + boost::is_nothrow_swappable

::value) { table_.swap(other.table_); } @@ -1756,8 +1756,8 @@ namespace boost { template void unordered_multiset::swap(unordered_multiset& other) BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&& - boost::unordered::detail::is_nothrow_swappable::value&& - boost::unordered::detail::is_nothrow_swappable

::value) + boost::is_nothrow_swappable::value&& + boost::is_nothrow_swappable

::value) { table_.swap(other.table_); } diff --git a/test/unordered/compile_tests.hpp b/test/unordered/compile_tests.hpp index 588414ec..691e4413 100644 --- a/test/unordered/compile_tests.hpp +++ b/test/unordered/compile_tests.hpp @@ -17,11 +17,12 @@ #endif #include "../helpers/check_return_type.hpp" -#include #include +#include #include #include #include +#include #include #include #include @@ -286,36 +287,47 @@ template void unordered_set_test(X& r, Key const&) BOOST_STATIC_ASSERT((boost::is_same::pointer>::value)); BOOST_STATIC_ASSERT((boost::is_same::element_type>::value)); - BOOST_STATIC_ASSERT((boost::is_same::difference_type>::value)); + BOOST_DEDUCED_TYPENAME + boost::pointer_traits::element_type>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::difference_type>::value)); // pointer_traits - BOOST_STATIC_ASSERT((boost::is_same::pointer>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::pointer>::value)); BOOST_STATIC_ASSERT((boost::is_same::element_type>::value)); - BOOST_STATIC_ASSERT((boost::is_same::difference_type>::value)); + BOOST_DEDUCED_TYPENAME + boost::pointer_traits::element_type>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::difference_type>::value)); // pointer_traits - BOOST_STATIC_ASSERT((boost::is_same::pointer>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::pointer>::value)); BOOST_STATIC_ASSERT((boost::is_same::element_type>::value)); - BOOST_STATIC_ASSERT((boost::is_same::difference_type>::value)); + BOOST_DEDUCED_TYPENAME + boost::pointer_traits::element_type>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::difference_type>::value)); // pointer_traits BOOST_STATIC_ASSERT((boost::is_same::pointer>::value)); + BOOST_DEDUCED_TYPENAME + boost::pointer_traits::pointer>::value)); BOOST_STATIC_ASSERT((boost::is_same::element_type>::value)); + BOOST_DEDUCED_TYPENAME + boost::pointer_traits::element_type>::value)); BOOST_STATIC_ASSERT((boost::is_same::difference_type>::value)); + BOOST_DEDUCED_TYPENAME + boost::pointer_traits::difference_type>::value)); typedef BOOST_DEDUCED_TYPENAME X::node_type node_type; typedef BOOST_DEDUCED_TYPENAME node_type::value_type node_value_type; @@ -366,37 +378,48 @@ void unordered_map_test(X& r, Key const& k, T const& v) BOOST_STATIC_ASSERT((boost::is_same::pointer>::value)); - BOOST_STATIC_ASSERT((boost::is_same::element_type>::value)); - BOOST_STATIC_ASSERT((boost::is_same::difference_type>::value)); + BOOST_STATIC_ASSERT( + (boost::is_same::element_type>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::difference_type>::value)); // pointer_traits - BOOST_STATIC_ASSERT((boost::is_same::pointer>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::pointer>::value)); BOOST_STATIC_ASSERT((boost::is_same::element_type>::value)); - BOOST_STATIC_ASSERT((boost::is_same::difference_type>::value)); + BOOST_DEDUCED_TYPENAME + boost::pointer_traits::element_type>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::difference_type>::value)); // pointer_traits - BOOST_STATIC_ASSERT((boost::is_same::pointer>::value)); - BOOST_STATIC_ASSERT((boost::is_same::element_type>::value)); - BOOST_STATIC_ASSERT((boost::is_same::difference_type>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::pointer>::value)); + BOOST_STATIC_ASSERT( + (boost::is_same::element_type>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::difference_type>::value)); // pointer_traits BOOST_STATIC_ASSERT((boost::is_same::pointer>::value)); + BOOST_DEDUCED_TYPENAME + boost::pointer_traits::pointer>::value)); BOOST_STATIC_ASSERT((boost::is_same::element_type>::value)); + BOOST_DEDUCED_TYPENAME + boost::pointer_traits::element_type>::value)); BOOST_STATIC_ASSERT((boost::is_same::difference_type>::value)); + BOOST_DEDUCED_TYPENAME + boost::pointer_traits::difference_type>::value)); typedef BOOST_DEDUCED_TYPENAME X::node_type node_type; typedef BOOST_DEDUCED_TYPENAME node_type::key_type node_key_type; diff --git a/test/unordered/noexcept_tests.cpp b/test/unordered/noexcept_tests.cpp index 4a28ce18..454e7c23 100644 --- a/test/unordered/noexcept_tests.cpp +++ b/test/unordered/noexcept_tests.cpp @@ -165,13 +165,12 @@ namespace noexcept_tests { !boost::is_nothrow_move_constructible::value); BOOST_TEST( !boost::is_nothrow_move_assignable::value); - BOOST_TEST(!boost::unordered::detail::is_nothrow_swappable< - hash_possible_exception>::value); + BOOST_TEST(!boost::is_nothrow_swappable::value); BOOST_TEST((!boost::is_nothrow_move_constructible< equal_to_nothrow >::value)); BOOST_TEST((!boost::is_nothrow_move_assignable< equal_to_nothrow >::value)); - BOOST_TEST((!boost::unordered::detail::is_nothrow_swappable< + BOOST_TEST((!boost::is_nothrow_swappable< equal_to_nothrow >::value)); have_is_nothrow_move = @@ -179,7 +178,7 @@ namespace noexcept_tests { have_is_nothrow_move_assign = boost::is_nothrow_move_assignable::value; have_is_nothrow_swap = - boost::unordered::detail::is_nothrow_swappable::value; + boost::is_nothrow_swappable::value; // Check that the traits work when expected. #if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) && \ @@ -191,8 +190,7 @@ namespace noexcept_tests { #if !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_NOEXCEPT) && \ !defined(BOOST_NO_CXX11_DECLTYPE) && \ !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) -// TODO: Turn test on when unordered starts to use is_nothrow_swap -// BOOST_TEST(have_is_nothrow_swap); + BOOST_TEST(have_is_nothrow_swap); #endif BOOST_LIGHTWEIGHT_TEST_OSTREAM @@ -286,8 +284,7 @@ namespace noexcept_tests { throwing_set; if (have_is_nothrow_swap) { - BOOST_TEST( - boost::unordered::detail::is_nothrow_swappable::value); + BOOST_TEST(boost::is_nothrow_swappable::value); } throwing_test_exception = false;