diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index f4dbeaf5..8aaf8d33 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -2060,6 +2060,10 @@ template class node_handle_map friend struct ::boost::unordered::detail::table_unique; template friend struct ::boost::unordered::detail::table_equiv; + template + friend class boost::unordered::unordered_map; + template + friend class boost::unordered::unordered_multimap; typedef typename boost::unordered::detail::rebind_wrap >::type value_allocator; @@ -2082,13 +2086,7 @@ template class node_handle_map bool has_alloc_; boost::unordered::detail::value_base alloc_; - public: - BOOST_CONSTEXPR node_handle_map() BOOST_NOEXCEPT : ptr_(), has_alloc_(false) - { - } - - /*BOOST_CONSTEXPR */ node_handle_map( - node_pointer ptr, allocator_type const& a) + node_handle_map(node_pointer ptr, allocator_type const& a) : ptr_(ptr), has_alloc_(false) { if (ptr_) { @@ -2097,6 +2095,11 @@ template class node_handle_map } } + public: + BOOST_CONSTEXPR node_handle_map() BOOST_NOEXCEPT : ptr_(), has_alloc_(false) + { + } + ~node_handle_map() { if (has_alloc_ && ptr_) { diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index fe1f2196..0c6b221a 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -1701,6 +1701,10 @@ template class node_handle_set friend struct ::boost::unordered::detail::table_unique; template friend struct ::boost::unordered::detail::table_equiv; + template + friend class unordered_set; + template + friend class unordered_multiset; typedef typename boost::unordered::detail::rebind_wrap::type value_allocator; @@ -1722,13 +1726,7 @@ template class node_handle_set bool has_alloc_; boost::unordered::detail::value_base alloc_; - public: - BOOST_CONSTEXPR node_handle_set() BOOST_NOEXCEPT : ptr_(), has_alloc_(false) - { - } - - /*BOOST_CONSTEXPR */ node_handle_set( - node_pointer ptr, allocator_type const& a) + node_handle_set(node_pointer ptr, allocator_type const& a) : ptr_(ptr), has_alloc_(false) { if (ptr_) { @@ -1737,6 +1735,11 @@ template class node_handle_set } } + public: + BOOST_CONSTEXPR node_handle_set() BOOST_NOEXCEPT : ptr_(), has_alloc_(false) + { + } + ~node_handle_set() { if (has_alloc_ && ptr_) { diff --git a/test/unordered/compile_tests.hpp b/test/unordered/compile_tests.hpp index babfd2fa..df49bf91 100644 --- a/test/unordered/compile_tests.hpp +++ b/test/unordered/compile_tests.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,23 @@ template void sink(T const&) {} template T rvalue(T const& v) { return v; } template T rvalue_default() { return T(); } +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) +template T implicit_construct() { return {}; } +#else +template int implicit_construct() +{ + T x; + sink(x); + return 0; +} +#endif + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) +#define TEST_NOEXCEPT_EXPR(x) BOOST_STATIC_ASSERT((BOOST_NOEXCEPT_EXPR(x))); +#else +#define TEST_NOEXCEPT_EXPR(x) +#endif + template void container_test(X& r, T const&) { typedef BOOST_DEDUCED_TYPENAME X::iterator iterator; @@ -52,6 +70,8 @@ template void container_test(X& r, T const&) typedef BOOST_DEDUCED_TYPENAME X::node_type node_type; + typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type; + // value_type BOOST_STATIC_ASSERT((boost::is_same::value)); @@ -75,7 +95,9 @@ template void container_test(X& r, T const&) BOOST_STATIC_ASSERT((boost::is_same::value)); // node_type - // TODO? + + BOOST_STATIC_ASSERT((boost::is_same::value)); // difference_type @@ -134,7 +156,6 @@ template void container_test(X& r, T const&) // Allocator - typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type; test::check_return_type::equals(a_const.get_allocator()); allocator_type m = a.get_allocator(); @@ -147,21 +168,26 @@ template void container_test(X& r, T const&) // node_type - typedef BOOST_DEDUCED_TYPENAME X::node_type node_type; - BOOST_STATIC_ASSERT((boost::is_same::value)); + implicit_construct(); + TEST_NOEXCEPT_EXPR(node_type()); node_type n1; node_type n2(rvalue_default()); + TEST_NOEXCEPT_EXPR(node_type(boost::move(n1))); node_type n3; n3 = boost::move(n2); n1.swap(n3); swap(n1, n3); + // TODO: noexcept for swap? + // value, key, mapped tests in map and set specific testing. node_type const n_const; BOOST_TEST(n_const ? 0 : 1); + TEST_NOEXCEPT_EXPR(n_const ? 0 : 1); test::check_return_type::equals(!n_const); test::check_return_type::equals(n_const.empty()); + TEST_NOEXCEPT_EXPR(!n_const); + TEST_NOEXCEPT_EXPR(n_const.empty()); // Avoid unused variable warnings: @@ -302,6 +328,8 @@ void unordered_map_test(X& r, Key const& k, T const& v) BOOST_STATIC_ASSERT((boost::is_same::value)); BOOST_STATIC_ASSERT((boost::is_same::value)); + // Superfluous,but just to make sure. + BOOST_STATIC_ASSERT((!boost::is_const::value)); // Calling functions @@ -329,6 +357,10 @@ void unordered_map_test(X& r, Key const& k, T const& v) r.insert(boost::move(n1)); r.insert(r.end(), r.extract(r.begin())); + + node_type n = r.extract(r.begin()); + test::check_return_type::equals_ref(n.key()); + test::check_return_type::equals_ref(n.mapped()); } template void equality_test(X& r)