mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-29 19:07:15 +02:00
Make node_handler constructor private + additional compile tests
This commit is contained in:
@ -2060,6 +2060,10 @@ template <typename N, class K, class T, class A> class node_handle_map
|
||||
friend struct ::boost::unordered::detail::table_unique;
|
||||
template <typename Types>
|
||||
friend struct ::boost::unordered::detail::table_equiv;
|
||||
template <class K2, class T2, class H2, class P2, class A2>
|
||||
friend class boost::unordered::unordered_map;
|
||||
template <class K2, class T2, class H2, class P2, class A2>
|
||||
friend class boost::unordered::unordered_multimap;
|
||||
|
||||
typedef typename boost::unordered::detail::rebind_wrap<A,
|
||||
std::pair<K const, T> >::type value_allocator;
|
||||
@ -2082,13 +2086,7 @@ template <typename N, class K, class T, class A> class node_handle_map
|
||||
bool has_alloc_;
|
||||
boost::unordered::detail::value_base<value_allocator> 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 <typename N, class K, class T, class A> class node_handle_map
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
BOOST_CONSTEXPR node_handle_map() BOOST_NOEXCEPT : ptr_(), has_alloc_(false)
|
||||
{
|
||||
}
|
||||
|
||||
~node_handle_map()
|
||||
{
|
||||
if (has_alloc_ && ptr_) {
|
||||
|
@ -1701,6 +1701,10 @@ template <typename N, typename T, typename A> class node_handle_set
|
||||
friend struct ::boost::unordered::detail::table_unique;
|
||||
template <typename Types>
|
||||
friend struct ::boost::unordered::detail::table_equiv;
|
||||
template <class T2, class H2, class P2, class A2>
|
||||
friend class unordered_set;
|
||||
template <class T2, class H2, class P2, class A2>
|
||||
friend class unordered_multiset;
|
||||
|
||||
typedef typename boost::unordered::detail::rebind_wrap<A, T>::type
|
||||
value_allocator;
|
||||
@ -1722,13 +1726,7 @@ template <typename N, typename T, typename A> class node_handle_set
|
||||
bool has_alloc_;
|
||||
boost::unordered::detail::value_base<value_allocator> 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 <typename N, typename T, typename A> class node_handle_set
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
BOOST_CONSTEXPR node_handle_set() BOOST_NOEXCEPT : ptr_(), has_alloc_(false)
|
||||
{
|
||||
}
|
||||
|
||||
~node_handle_set()
|
||||
{
|
||||
if (has_alloc_ && ptr_) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/cv_traits.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/utility/swap.hpp>
|
||||
@ -30,6 +31,23 @@ template <class T> void sink(T const&) {}
|
||||
template <class T> T rvalue(T const& v) { return v; }
|
||||
template <class T> T rvalue_default() { return T(); }
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
template <class T> T implicit_construct() { return {}; }
|
||||
#else
|
||||
template <class T> 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 <class X, class T> void container_test(X& r, T const&)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
@ -52,6 +70,8 @@ template <class X, class T> 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<T, value_type>::value));
|
||||
@ -75,7 +95,9 @@ template <class X, class T> void container_test(X& r, T const&)
|
||||
BOOST_STATIC_ASSERT((boost::is_same<T, const_iterator_value_type>::value));
|
||||
|
||||
// node_type
|
||||
// TODO?
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<allocator_type,
|
||||
BOOST_DEDUCED_TYPENAME node_type::allocator_type>::value));
|
||||
|
||||
// difference_type
|
||||
|
||||
@ -134,7 +156,6 @@ template <class X, class T> void container_test(X& r, T const&)
|
||||
|
||||
// Allocator
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
|
||||
test::check_return_type<allocator_type>::equals(a_const.get_allocator());
|
||||
|
||||
allocator_type m = a.get_allocator();
|
||||
@ -147,21 +168,26 @@ template <class X, class T> void container_test(X& r, T const&)
|
||||
|
||||
// node_type
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
|
||||
BOOST_STATIC_ASSERT((boost::is_same<allocator_type,
|
||||
BOOST_DEDUCED_TYPENAME node_type::allocator_type>::value));
|
||||
implicit_construct<node_type const>();
|
||||
TEST_NOEXCEPT_EXPR(node_type());
|
||||
|
||||
node_type n1;
|
||||
node_type n2(rvalue_default<node_type>());
|
||||
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<bool>::equals(!n_const);
|
||||
test::check_return_type<bool>::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<Key, node_key_type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<T, node_mapped_type>::value));
|
||||
// Superfluous,but just to make sure.
|
||||
BOOST_STATIC_ASSERT((!boost::is_const<node_key_type>::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<node_key_type>::equals_ref(n.key());
|
||||
test::check_return_type<node_mapped_type>::equals_ref(n.mapped());
|
||||
}
|
||||
|
||||
template <class X> void equality_test(X& r)
|
||||
|
Reference in New Issue
Block a user