mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-31 20:04:29 +02:00
Move constructor implementation into containers
This commit is contained in:
@@ -3729,34 +3729,21 @@ struct table_unique : boost::unordered::detail::table<Types>
|
||||
: table(x, node_allocator_traits::select_on_container_copy_construction(
|
||||
x.node_alloc()))
|
||||
{
|
||||
if (x.size_) {
|
||||
this->copy_buckets(x);
|
||||
}
|
||||
}
|
||||
|
||||
table_unique(table_unique const& x, node_allocator const& a) : table(x, a)
|
||||
{
|
||||
if (x.size_) {
|
||||
this->copy_buckets(x);
|
||||
}
|
||||
}
|
||||
|
||||
table_unique(table_unique& x, boost::unordered::detail::move_tag m)
|
||||
: table(x, m)
|
||||
{
|
||||
// The move is done in the base class.
|
||||
}
|
||||
|
||||
table_unique(table_unique& x, node_allocator const& a,
|
||||
boost::unordered::detail::move_tag m)
|
||||
: table(x, a, m)
|
||||
{
|
||||
if (this->node_alloc() == x.node_alloc()) {
|
||||
this->move_buckets_from(x);
|
||||
} else if (x.size_) {
|
||||
// TODO: Could pick new bucket size?
|
||||
this->move_buckets(x);
|
||||
}
|
||||
}
|
||||
|
||||
// equals
|
||||
@@ -4438,34 +4425,19 @@ struct table_equiv : boost::unordered::detail::table<Types>
|
||||
: table(x, node_allocator_traits::select_on_container_copy_construction(
|
||||
x.node_alloc()))
|
||||
{
|
||||
if (x.size_) {
|
||||
copy_buckets(x);
|
||||
}
|
||||
}
|
||||
|
||||
table_equiv(table_equiv const& x, node_allocator const& a) : table(x, a)
|
||||
{
|
||||
if (x.size_) {
|
||||
copy_buckets(x);
|
||||
}
|
||||
}
|
||||
table_equiv(table_equiv const& x, node_allocator const& a) : table(x, a) {}
|
||||
|
||||
table_equiv(table_equiv& x, boost::unordered::detail::move_tag m)
|
||||
: table(x, m)
|
||||
{
|
||||
// The move is done in the base class.
|
||||
}
|
||||
|
||||
table_equiv(table_equiv& x, node_allocator const& a,
|
||||
boost::unordered::detail::move_tag m)
|
||||
: table(x, a, m)
|
||||
{
|
||||
if (this->node_alloc() == x.node_alloc()) {
|
||||
this->move_buckets_from(x);
|
||||
} else if (x.size_) {
|
||||
// TODO: Could pick new bucket size?
|
||||
this->move_buckets_equiv(x);
|
||||
}
|
||||
}
|
||||
|
||||
// Equality
|
||||
|
@@ -101,6 +101,7 @@ template <class K, class T, class H, class P, class A> class unordered_map
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
// The move is done in table_
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -883,6 +884,7 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
// The move is done in table_
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1378,6 +1380,9 @@ template <class K, class T, class H, class P, class A>
|
||||
unordered_map<K, T, H, P, A>::unordered_map(unordered_map const& other)
|
||||
: table_(other.table_)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
@@ -1392,6 +1397,9 @@ unordered_map<K, T, H, P, A>::unordered_map(
|
||||
unordered_map const& other, allocator_type const& a)
|
||||
: table_(other.table_, a)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
@@ -1399,6 +1407,12 @@ unordered_map<K, T, H, P, A>::unordered_map(
|
||||
BOOST_RV_REF(unordered_map) other, allocator_type const& a)
|
||||
: table_(other.table_, a, boost::unordered::detail::move_tag())
|
||||
{
|
||||
if (table_.node_alloc() == other.table_.node_alloc()) {
|
||||
table_.move_buckets_from(other.table_);
|
||||
} else if (other.table_.size_) {
|
||||
// TODO: Could pick new bucket size?
|
||||
table_.move_buckets(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
@@ -1854,6 +1868,9 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(
|
||||
unordered_multimap const& other)
|
||||
: table_(other.table_)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
@@ -1868,6 +1885,9 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(
|
||||
unordered_multimap const& other, allocator_type const& a)
|
||||
: table_(other.table_, a)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
@@ -1875,6 +1895,12 @@ unordered_multimap<K, T, H, P, A>::unordered_multimap(
|
||||
BOOST_RV_REF(unordered_multimap) other, allocator_type const& a)
|
||||
: table_(other.table_, a, boost::unordered::detail::move_tag())
|
||||
{
|
||||
if (table_.node_alloc() == other.table_.node_alloc()) {
|
||||
table_.move_buckets_from(other.table_);
|
||||
} else if (other.table_.size()) {
|
||||
// TODO: Could pick new bucket size?
|
||||
table_.move_buckets_equiv(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
|
@@ -99,6 +99,7 @@ template <class T, class H, class P, class A> class unordered_set
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
// The move is done in table_
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -609,6 +610,7 @@ template <class T, class H, class P, class A> class unordered_multiset
|
||||
BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
||||
: table_(other.table_, boost::unordered::detail::move_tag())
|
||||
{
|
||||
// The move is done in table_
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1077,6 +1079,9 @@ template <class T, class H, class P, class A>
|
||||
unordered_set<T, H, P, A>::unordered_set(unordered_set const& other)
|
||||
: table_(other.table_)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
@@ -1091,6 +1096,9 @@ unordered_set<T, H, P, A>::unordered_set(
|
||||
unordered_set const& other, allocator_type const& a)
|
||||
: table_(other.table_, a)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
@@ -1098,6 +1106,12 @@ unordered_set<T, H, P, A>::unordered_set(
|
||||
BOOST_RV_REF(unordered_set) other, allocator_type const& a)
|
||||
: table_(other.table_, a, boost::unordered::detail::move_tag())
|
||||
{
|
||||
if (table_.node_alloc() == other.table_.node_alloc()) {
|
||||
table_.move_buckets_from(other.table_);
|
||||
} else if (other.table_.size_) {
|
||||
// TODO: Could pick new bucket size?
|
||||
table_.move_buckets(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
@@ -1468,6 +1482,9 @@ unordered_multiset<T, H, P, A>::unordered_multiset(
|
||||
unordered_multiset const& other)
|
||||
: table_(other.table_)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
@@ -1482,6 +1499,9 @@ unordered_multiset<T, H, P, A>::unordered_multiset(
|
||||
unordered_multiset const& other, allocator_type const& a)
|
||||
: table_(other.table_, a)
|
||||
{
|
||||
if (other.table_.size_) {
|
||||
table_.copy_buckets(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
@@ -1489,6 +1509,12 @@ unordered_multiset<T, H, P, A>::unordered_multiset(
|
||||
BOOST_RV_REF(unordered_multiset) other, allocator_type const& a)
|
||||
: table_(other.table_, a, boost::unordered::detail::move_tag())
|
||||
{
|
||||
if (table_.node_alloc() == other.table_.node_alloc()) {
|
||||
table_.move_buckets_from(other.table_);
|
||||
} else if (other.table_.size()) {
|
||||
// TODO: Could pick new bucket size?
|
||||
table_.move_buckets_equiv(other.table_);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
|
Reference in New Issue
Block a user