Remove usage of BOOST_NO_CXX11_HDR_TYPE_TRAITS

This commit is contained in:
Christian Mazakas
2023-08-29 09:53:40 -07:00
parent 8cbd9ad80a
commit 59a7fa09ba
3 changed files with 40 additions and 117 deletions

View File

@ -60,9 +60,7 @@
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
#include <type_traits> #include <type_traits>
#endif
#if BOOST_UNORDERED_CXX11_CONSTRUCTION #if BOOST_UNORDERED_CXX11_CONSTRUCTION
#include <boost/mp11/algorithm.hpp> #include <boost/mp11/algorithm.hpp>
@ -369,33 +367,6 @@ namespace boost {
namespace unordered { namespace unordered {
namespace detail { namespace detail {
////////////////////////////////////////////////////////////////////////////
// Integral_constrant, true_type, false_type
//
// Uses the standard versions if available.
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
using std::false_type;
using std::integral_constant;
using std::true_type;
#else
template <typename T, T Value> struct integral_constant
{
enum
{
value = Value
};
};
typedef boost::unordered::detail::integral_constant<bool, true> true_type;
typedef boost::unordered::detail::integral_constant<bool, false>
false_type;
#endif
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Explicitly call a destructor // Explicitly call a destructor
@ -1357,8 +1328,7 @@ namespace boost {
: current_(0) : current_(0)
{ {
construct_functions(current_, bf.current_functions(), construct_functions(current_, bf.current_functions(),
boost::unordered::detail::integral_constant<bool, std::integral_constant<bool, nothrow_move_constructible>());
nothrow_move_constructible>());
} }
~functions() ~functions()
@ -1414,16 +1384,15 @@ namespace boost {
new ((void*)&funcs_[which]) function_pair(hf, eq); new ((void*)&funcs_[which]) function_pair(hf, eq);
} }
void construct_functions(unsigned char which, function_pair const& f, void construct_functions(
boost::unordered::detail::false_type = unsigned char which, function_pair const& f, std::false_type = {})
boost::unordered::detail::false_type())
{ {
BOOST_ASSERT(!(which & 2)); BOOST_ASSERT(!(which & 2));
new ((void*)&funcs_[which]) function_pair(f); new ((void*)&funcs_[which]) function_pair(f);
} }
void construct_functions(unsigned char which, function_pair& f, void construct_functions(
boost::unordered::detail::true_type) unsigned char which, function_pair& f, std::true_type)
{ {
BOOST_ASSERT(!(which & 2)); BOOST_ASSERT(!(which & 2));
new ((void*)&funcs_[which]) new ((void*)&funcs_[which])
@ -1922,7 +1891,7 @@ namespace boost {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Swap and Move // Swap and Move
void swap_allocators(table& other, false_type) void swap_allocators(table& other, std::false_type)
{ {
boost::unordered::detail::func::ignore_unused_variable_warning(other); boost::unordered::detail::func::ignore_unused_variable_warning(other);
@ -1933,7 +1902,7 @@ namespace boost {
} }
// Not nothrow swappable // Not nothrow swappable
void swap(table& x, false_type) void swap(table& x, std::false_type)
{ {
if (this == &x) { if (this == &x) {
return; return;
@ -1957,7 +1926,7 @@ namespace boost {
} }
// Nothrow swappable // Nothrow swappable
void swap(table& x, true_type) void swap(table& x, std::true_type)
{ {
buckets_.swap(x.buckets_); buckets_.swap(x.buckets_);
boost::core::invoke_swap(size_, x.size_); boost::core::invoke_swap(size_, x.size_);
@ -1974,8 +1943,7 @@ namespace boost {
BOOST_ASSERT(boost::allocator_propagate_on_container_swap< BOOST_ASSERT(boost::allocator_propagate_on_container_swap<
node_allocator_type>::type::value || node_allocator_type>::type::value ||
node_alloc() == x.node_alloc()); node_alloc() == x.node_alloc());
swap(x, boost::unordered::detail::integral_constant<bool, swap(x, std::integral_constant<bool, functions::nothrow_swappable>());
functions::nothrow_swappable>());
} }
// Only call with nodes allocated with the currect allocator, or // Only call with nodes allocated with the currect allocator, or
@ -2066,14 +2034,12 @@ namespace boost {
node_allocator_type>::type pocca; node_allocator_type>::type pocca;
if (this != &x) { if (this != &x) {
assign(x, is_unique, assign(x, is_unique, std::integral_constant<bool, pocca::value>());
boost::unordered::detail::integral_constant<bool,
pocca::value>());
} }
} }
template <typename UniqueType> template <typename UniqueType>
void assign(table const& x, UniqueType is_unique, false_type) void assign(table const& x, UniqueType is_unique, std::false_type)
{ {
// Strong exception safety. // Strong exception safety.
this->construct_spare_functions(x.current_functions()); this->construct_spare_functions(x.current_functions());
@ -2096,11 +2062,11 @@ namespace boost {
} }
template <typename UniqueType> template <typename UniqueType>
void assign(table const& x, UniqueType is_unique, true_type) void assign(table const& x, UniqueType is_unique, std::true_type)
{ {
if (node_alloc() == x.node_alloc()) { if (node_alloc() == x.node_alloc()) {
buckets_.reset_allocator(x.node_alloc()); buckets_.reset_allocator(x.node_alloc());
assign(x, is_unique, false_type()); assign(x, is_unique, std::false_type());
} else { } else {
bucket_array_type new_buckets(x.size_, x.node_alloc()); bucket_array_type new_buckets(x.size_, x.node_alloc());
this->construct_spare_functions(x.current_functions()); this->construct_spare_functions(x.current_functions());
@ -2128,7 +2094,7 @@ namespace boost {
{ {
if (this != &x) { if (this != &x) {
move_assign(x, is_unique, move_assign(x, is_unique,
boost::unordered::detail::integral_constant<bool, std::integral_constant<bool,
boost::allocator_propagate_on_container_move_assignment< boost::allocator_propagate_on_container_move_assignment<
node_allocator_type>::type::value>()); node_allocator_type>::type::value>());
} }
@ -2136,7 +2102,7 @@ namespace boost {
// Propagate allocator // Propagate allocator
template <typename UniqueType> template <typename UniqueType>
void move_assign(table& x, UniqueType, true_type) void move_assign(table& x, UniqueType, std::true_type)
{ {
if (!functions::nothrow_move_assignable) { if (!functions::nothrow_move_assignable) {
this->construct_spare_functions(x.current_functions()); this->construct_spare_functions(x.current_functions());
@ -2153,7 +2119,7 @@ namespace boost {
// Don't propagate allocator // Don't propagate allocator
template <typename UniqueType> template <typename UniqueType>
void move_assign(table& x, UniqueType is_unique, false_type) void move_assign(table& x, UniqueType is_unique, std::false_type)
{ {
if (node_alloc() == x.node_alloc()) { if (node_alloc() == x.node_alloc()) {
move_assign_equal_alloc(x); move_assign_equal_alloc(x);
@ -2789,7 +2755,7 @@ namespace boost {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// fill_buckets_unique // fill_buckets_unique
void copy_buckets(table const& src, true_type) void copy_buckets(table const& src, std::true_type)
{ {
BOOST_ASSERT(size_ == 0); BOOST_ASSERT(size_ == 0);
@ -2810,7 +2776,7 @@ namespace boost {
} }
} }
void move_assign_buckets(table& src, true_type) void move_assign_buckets(table& src, std::true_type)
{ {
BOOST_ASSERT(size_ == 0); BOOST_ASSERT(size_ == 0);
BOOST_ASSERT(max_load_ >= src.size_); BOOST_ASSERT(max_load_ >= src.size_);
@ -3135,7 +3101,7 @@ namespace boost {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// fill_buckets // fill_buckets
void copy_buckets(table const& src, false_type) void copy_buckets(table const& src, std::false_type)
{ {
BOOST_ASSERT(size_ == 0); BOOST_ASSERT(size_ == 0);
@ -3156,7 +3122,7 @@ namespace boost {
} }
} }
void move_assign_buckets(table& src, false_type) void move_assign_buckets(table& src, std::false_type)
{ {
BOOST_ASSERT(size_ == 0); BOOST_ASSERT(size_ == 0);
BOOST_ASSERT(max_load_ >= src.size_); BOOST_ASSERT(max_load_ >= src.size_);

View File

@ -149,7 +149,7 @@ namespace boost {
#if defined(BOOST_UNORDERED_USE_MOVE) #if defined(BOOST_UNORDERED_USE_MOVE)
unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x) unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x)
{ {
table_.assign(x.table_, boost::unordered::detail::true_type()); table_.assign(x.table_, std::true_type());
return *this; return *this;
} }
@ -158,13 +158,13 @@ namespace boost {
boost::is_nothrow_move_assignable<H>::value&& boost::is_nothrow_move_assignable<H>::value&&
boost::is_nothrow_move_assignable<P>::value) boost::is_nothrow_move_assignable<P>::value)
{ {
table_.move_assign(x.table_, boost::unordered::detail::true_type()); table_.move_assign(x.table_, std::true_type());
return *this; return *this;
} }
#else #else
unordered_map& operator=(unordered_map const& x) unordered_map& operator=(unordered_map const& x)
{ {
table_.assign(x.table_, boost::unordered::detail::true_type()); table_.assign(x.table_, std::true_type());
return *this; return *this;
} }
@ -174,7 +174,7 @@ namespace boost {
boost::is_nothrow_move_assignable<H>::value&& boost::is_nothrow_move_assignable<H>::value&&
boost::is_nothrow_move_assignable<P>::value) boost::is_nothrow_move_assignable<P>::value)
{ {
table_.move_assign(x.table_, boost::unordered::detail::true_type()); table_.move_assign(x.table_, std::true_type());
return *this; return *this;
} }
#endif #endif
@ -1247,39 +1247,20 @@ namespace boost {
// Assign // Assign
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multimap& operator=(BOOST_COPY_ASSIGN_REF(unordered_multimap) x)
{
table_.assign(x.table_, boost::unordered::detail::false_type());
return *this;
}
unordered_multimap& operator=(BOOST_RV_REF(unordered_multimap) x)
noexcept(value_allocator_traits::is_always_equal::value&&
boost::is_nothrow_move_assignable<H>::value&&
boost::is_nothrow_move_assignable<P>::value)
{
table_.move_assign(x.table_, boost::unordered::detail::false_type());
return *this;
}
#else
unordered_multimap& operator=(unordered_multimap const& x) unordered_multimap& operator=(unordered_multimap const& x)
{ {
table_.assign(x.table_, boost::unordered::detail::false_type()); table_.assign(x.table_, std::false_type());
return *this; return *this;
} }
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
unordered_multimap& operator=(unordered_multimap&& x) unordered_multimap& operator=(unordered_multimap&& x)
noexcept(value_allocator_traits::is_always_equal::value&& noexcept(value_allocator_traits::is_always_equal::value&&
boost::is_nothrow_move_assignable<H>::value&& boost::is_nothrow_move_assignable<H>::value&&
boost::is_nothrow_move_assignable<P>::value) boost::is_nothrow_move_assignable<P>::value)
{ {
table_.move_assign(x.table_, boost::unordered::detail::false_type()); table_.move_assign(x.table_, std::false_type());
return *this; return *this;
} }
#endif
#endif
unordered_multimap& operator=(std::initializer_list<value_type>); unordered_multimap& operator=(std::initializer_list<value_type>);
@ -1869,7 +1850,7 @@ namespace boost {
{ {
if (other.size()) { if (other.size()) {
table_.copy_buckets( table_.copy_buckets(
other.table_, boost::unordered::detail::true_type()); other.table_, std::true_type());
} }
} }
@ -1887,7 +1868,7 @@ namespace boost {
{ {
if (other.table_.size_) { if (other.table_.size_) {
table_.copy_buckets( table_.copy_buckets(
other.table_, boost::unordered::detail::true_type()); other.table_, std::true_type());
} }
} }
@ -2402,7 +2383,7 @@ namespace boost {
{ {
if (other.table_.size_) { if (other.table_.size_) {
table_.copy_buckets( table_.copy_buckets(
other.table_, boost::unordered::detail::false_type()); other.table_, std::false_type());
} }
} }
@ -2421,7 +2402,7 @@ namespace boost {
{ {
if (other.table_.size_) { if (other.table_.size_) {
table_.copy_buckets( table_.copy_buckets(
other.table_, boost::unordered::detail::false_type()); other.table_, std::false_type());
} }
} }

View File

@ -147,7 +147,7 @@ namespace boost {
#if defined(BOOST_UNORDERED_USE_MOVE) #if defined(BOOST_UNORDERED_USE_MOVE)
unordered_set& operator=(BOOST_COPY_ASSIGN_REF(unordered_set) x) unordered_set& operator=(BOOST_COPY_ASSIGN_REF(unordered_set) x)
{ {
table_.assign(x.table_, boost::unordered::detail::true_type()); table_.assign(x.table_, std::true_type());
return *this; return *this;
} }
@ -156,13 +156,13 @@ namespace boost {
boost::is_nothrow_move_assignable<H>::value&& boost::is_nothrow_move_assignable<H>::value&&
boost::is_nothrow_move_assignable<P>::value) boost::is_nothrow_move_assignable<P>::value)
{ {
table_.move_assign(x.table_, boost::unordered::detail::true_type()); table_.move_assign(x.table_, std::true_type());
return *this; return *this;
} }
#else #else
unordered_set& operator=(unordered_set const& x) unordered_set& operator=(unordered_set const& x)
{ {
table_.assign(x.table_, boost::unordered::detail::true_type()); table_.assign(x.table_, std::true_type());
return *this; return *this;
} }
@ -172,7 +172,7 @@ namespace boost {
boost::is_nothrow_move_assignable<H>::value&& boost::is_nothrow_move_assignable<H>::value&&
boost::is_nothrow_move_assignable<P>::value) boost::is_nothrow_move_assignable<P>::value)
{ {
table_.move_assign(x.table_, boost::unordered::detail::true_type()); table_.move_assign(x.table_, std::true_type());
return *this; return *this;
} }
#endif #endif
@ -818,40 +818,20 @@ namespace boost {
~unordered_multiset() noexcept; ~unordered_multiset() noexcept;
// Assign // Assign
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multiset& operator=(BOOST_COPY_ASSIGN_REF(unordered_multiset) x)
{
table_.assign(x.table_, boost::unordered::detail::false_type());
return *this;
}
unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x)
noexcept(value_allocator_traits::is_always_equal::value&&
boost::is_nothrow_move_assignable<H>::value&&
boost::is_nothrow_move_assignable<P>::value)
{
table_.move_assign(x.table_, boost::unordered::detail::false_type());
return *this;
}
#else
unordered_multiset& operator=(unordered_multiset const& x) unordered_multiset& operator=(unordered_multiset const& x)
{ {
table_.assign(x.table_, boost::unordered::detail::false_type()); table_.assign(x.table_, std::false_type());
return *this; return *this;
} }
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
unordered_multiset& operator=(unordered_multiset&& x) unordered_multiset& operator=(unordered_multiset&& x)
noexcept(value_allocator_traits::is_always_equal::value&& noexcept(value_allocator_traits::is_always_equal::value&&
boost::is_nothrow_move_assignable<H>::value&& boost::is_nothrow_move_assignable<H>::value&&
boost::is_nothrow_move_assignable<P>::value) boost::is_nothrow_move_assignable<P>::value)
{ {
table_.move_assign(x.table_, boost::unordered::detail::false_type()); table_.move_assign(x.table_, std::false_type());
return *this; return *this;
} }
#endif
#endif
unordered_multiset& operator=(std::initializer_list<value_type>); unordered_multiset& operator=(std::initializer_list<value_type>);
@ -1389,8 +1369,7 @@ namespace boost {
select_on_container_copy_construction(other.get_allocator())) select_on_container_copy_construction(other.get_allocator()))
{ {
if (other.size()) { if (other.size()) {
table_.copy_buckets( table_.copy_buckets(other.table_, std::true_type());
other.table_, boost::unordered::detail::true_type());
} }
} }
@ -1407,8 +1386,7 @@ namespace boost {
: table_(other.table_, a) : table_(other.table_, a)
{ {
if (other.table_.size_) { if (other.table_.size_) {
table_.copy_buckets( table_.copy_buckets(other.table_, std::true_type());
other.table_, boost::unordered::detail::true_type());
} }
} }
@ -1793,8 +1771,7 @@ namespace boost {
select_on_container_copy_construction(other.get_allocator())) select_on_container_copy_construction(other.get_allocator()))
{ {
if (other.table_.size_) { if (other.table_.size_) {
table_.copy_buckets( table_.copy_buckets(other.table_, std::false_type());
other.table_, boost::unordered::detail::false_type());
} }
} }
@ -1811,8 +1788,7 @@ namespace boost {
: table_(other.table_, a) : table_(other.table_, a)
{ {
if (other.table_.size_) { if (other.table_.size_) {
table_.copy_buckets( table_.copy_buckets(other.table_, std::false_type());
other.table_, boost::unordered::detail::false_type());
} }
} }