forked from boostorg/container
Sync from upstream.
This commit is contained in:
commit
5f43b093c7
15 files changed
+454
-109
No files matched your search
@@ -104,7 +104,6 @@ public:
|
||||
recursive_deque & operator=(const recursive_deque &x)
|
||||
{ this->deque_ = x.deque_; return *this; }
|
||||
|
||||
int id_;
|
||||
deque<recursive_deque> deque_;
|
||||
deque<recursive_deque>::iterator it_;
|
||||
deque<recursive_deque>::const_iterator cit_;
|
||||
|
||||
@@ -3881,7 +3881,6 @@ class recursive_devector
|
||||
recursive_devector & operator=(const recursive_devector &x)
|
||||
{ this->devector_ = x.devector_; return *this; }
|
||||
|
||||
int id_;
|
||||
devector<recursive_devector> devector_;
|
||||
devector<recursive_devector>::iterator it_;
|
||||
devector<recursive_devector>::const_iterator cit_;
|
||||
|
||||
@@ -32,17 +32,15 @@ class recursive_flat_map
|
||||
{
|
||||
public:
|
||||
recursive_flat_map(const recursive_flat_map &c)
|
||||
: id_(c.id_), map_(c.map_)
|
||||
: map_(c.map_)
|
||||
{}
|
||||
|
||||
recursive_flat_map & operator =(const recursive_flat_map &c)
|
||||
{
|
||||
id_ = c.id_;
|
||||
map_= c.map_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int id_;
|
||||
flat_map<recursive_flat_map, recursive_flat_map> map_;
|
||||
flat_map<recursive_flat_map, recursive_flat_map>::iterator it_;
|
||||
flat_map<recursive_flat_map, recursive_flat_map>::const_iterator cit_;
|
||||
@@ -50,7 +48,7 @@ class recursive_flat_map
|
||||
flat_map<recursive_flat_map, recursive_flat_map>::const_reverse_iterator crit_;
|
||||
|
||||
friend bool operator< (const recursive_flat_map &a, const recursive_flat_map &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
{ return a.map_ < b.map_; }
|
||||
};
|
||||
|
||||
|
||||
@@ -58,16 +56,14 @@ class recursive_flat_multimap
|
||||
{
|
||||
public:
|
||||
recursive_flat_multimap(const recursive_flat_multimap &c)
|
||||
: id_(c.id_), map_(c.map_)
|
||||
: map_(c.map_)
|
||||
{}
|
||||
|
||||
recursive_flat_multimap & operator =(const recursive_flat_multimap &c)
|
||||
{
|
||||
id_ = c.id_;
|
||||
map_= c.map_;
|
||||
return *this;
|
||||
}
|
||||
int id_;
|
||||
flat_multimap<recursive_flat_multimap, recursive_flat_multimap> map_;
|
||||
flat_multimap<recursive_flat_multimap, recursive_flat_multimap>::iterator it_;
|
||||
flat_multimap<recursive_flat_multimap, recursive_flat_multimap>::const_iterator cit_;
|
||||
@@ -75,7 +71,7 @@ public:
|
||||
flat_multimap<recursive_flat_multimap, recursive_flat_multimap>::const_reverse_iterator crit_;
|
||||
|
||||
friend bool operator< (const recursive_flat_multimap &a, const recursive_flat_multimap &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
{ return a.map_ < b.map_; }
|
||||
};
|
||||
|
||||
template<class C>
|
||||
|
||||
@@ -48,7 +48,6 @@ template class iterator_from_iiterator
|
||||
class recursive_list
|
||||
{
|
||||
public:
|
||||
int id_;
|
||||
list<recursive_list> list_;
|
||||
list<recursive_list>::iterator it_;
|
||||
list<recursive_list>::const_iterator cit_;
|
||||
|
||||
+4
-6
@@ -35,9 +35,8 @@ class recursive_map
|
||||
{}
|
||||
|
||||
recursive_map & operator=(const recursive_map &x)
|
||||
{ id_ = x.id_; map_ = x.map_; return *this; }
|
||||
{ map_ = x.map_; return *this; }
|
||||
|
||||
int id_;
|
||||
map<recursive_map, recursive_map> map_;
|
||||
map<recursive_map, recursive_map>::iterator it_;
|
||||
map<recursive_map, recursive_map>::const_iterator cit_;
|
||||
@@ -45,7 +44,7 @@ class recursive_map
|
||||
map<recursive_map, recursive_map>::const_reverse_iterator crit_;
|
||||
|
||||
friend bool operator< (const recursive_map &a, const recursive_map &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
{ return a.map_ < b.map_; }
|
||||
};
|
||||
|
||||
class recursive_multimap
|
||||
@@ -59,9 +58,8 @@ class recursive_multimap
|
||||
{}
|
||||
|
||||
recursive_multimap & operator=(const recursive_multimap &x)
|
||||
{ id_ = x.id_; multimap_ = x.multimap_; return *this; }
|
||||
{ multimap_ = x.multimap_; return *this; }
|
||||
|
||||
int id_;
|
||||
multimap<recursive_multimap, recursive_multimap> multimap_;
|
||||
multimap<recursive_multimap, recursive_multimap>::iterator it_;
|
||||
multimap<recursive_multimap, recursive_multimap>::const_iterator cit_;
|
||||
@@ -69,7 +67,7 @@ class recursive_multimap
|
||||
multimap<recursive_multimap, recursive_multimap>::const_reverse_iterator crit_;
|
||||
|
||||
friend bool operator< (const recursive_multimap &a, const recursive_multimap &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
{ return a.multimap_ < b.multimap_; }
|
||||
};
|
||||
|
||||
template<class C>
|
||||
|
||||
+1
-1
@@ -311,7 +311,7 @@ int map_test_range()
|
||||
|
||||
::boost::movelib::unique_ptr<MyBoostMap> const pboostmap = ::boost::movelib::make_unique<MyBoostMap>
|
||||
( boost::make_move_iterator(&aux_vect[0])
|
||||
, boost::make_move_iterator(&aux_vect[0] + MaxElem), typename MyBoostMap::allocator_type());
|
||||
, boost::make_move_iterator(&aux_vect[0] + MaxElem));
|
||||
::boost::movelib::unique_ptr<MyStdMap> const pstdmap = ::boost::movelib::make_unique<MyStdMap>
|
||||
(&aux_vect2[0], &aux_vect2[0] + MaxElem, typename MyStdMap::key_compare());
|
||||
if(!CheckEqualContainers(*pboostmap, *pstdmap)) return 1;
|
||||
|
||||
+5
-6
@@ -26,6 +26,7 @@ using namespace boost::container;
|
||||
class recursive_set
|
||||
{
|
||||
public:
|
||||
|
||||
recursive_set()
|
||||
{}
|
||||
|
||||
@@ -34,9 +35,8 @@ public:
|
||||
{}
|
||||
|
||||
recursive_set & operator=(const recursive_set &x)
|
||||
{ id_ = x.id_; set_ = x.set_; return *this; }
|
||||
{ set_ = x.set_; return *this; }
|
||||
|
||||
int id_;
|
||||
set<recursive_set> set_;
|
||||
set<recursive_set>::iterator it_;
|
||||
set<recursive_set>::const_iterator cit_;
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
set<recursive_set>::const_reverse_iterator crit_;
|
||||
|
||||
friend bool operator< (const recursive_set &a, const recursive_set &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
{ return a.set_ < b.set_; }
|
||||
};
|
||||
|
||||
//Test recursive structures
|
||||
@@ -59,9 +59,8 @@ class recursive_multiset
|
||||
{}
|
||||
|
||||
recursive_multiset & operator=(const recursive_multiset &x)
|
||||
{ id_ = x.id_; multiset_ = x.multiset_; return *this; }
|
||||
{ multiset_ = x.multiset_; return *this; }
|
||||
|
||||
int id_;
|
||||
multiset<recursive_multiset> multiset_;
|
||||
multiset<recursive_multiset>::iterator it_;
|
||||
multiset<recursive_multiset>::const_iterator cit_;
|
||||
@@ -69,7 +68,7 @@ class recursive_multiset
|
||||
multiset<recursive_multiset>::const_reverse_iterator crit_;
|
||||
|
||||
friend bool operator< (const recursive_multiset &a, const recursive_multiset &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
{ return a.multiset_ < b.multiset_; }
|
||||
};
|
||||
|
||||
template<class C>
|
||||
|
||||
@@ -24,7 +24,6 @@ using namespace boost::container;
|
||||
class recursive_slist
|
||||
{
|
||||
public:
|
||||
int id_;
|
||||
slist<recursive_slist> slist_;
|
||||
slist<recursive_slist>::iterator it_;
|
||||
slist<recursive_slist>::const_iterator cit_;
|
||||
|
||||
+218
-2
@@ -84,6 +84,140 @@ bool test_small_vector_base_test()
|
||||
if (!boost::container::test::CheckEqualContainers(sm5_move, sm5_copy))
|
||||
return false;
|
||||
}
|
||||
{
|
||||
typedef boost::container::small_vector<int, 5> sm5_t;
|
||||
typedef boost::container::small_vector<int, 7> sm7_t;
|
||||
|
||||
{
|
||||
//Both in static memory
|
||||
sm5_t sm5;
|
||||
sm5.push_back(1);
|
||||
|
||||
sm7_t sm7;
|
||||
sm7.push_back(2);
|
||||
|
||||
sm5_t sm5_copy(sm5);
|
||||
sm7_t sm7_copy(sm7);
|
||||
smb_t& smb5 = sm5_copy;
|
||||
smb_t& smb7 = sm7_copy;
|
||||
if (!sm5.is_small() || !sm7.is_small())
|
||||
return false;
|
||||
|
||||
smb5.swap(smb7);
|
||||
if (!boost::container::test::CheckEqualContainers(sm5_copy, sm7))
|
||||
return false;
|
||||
if (!boost::container::test::CheckEqualContainers(sm7_copy, sm5))
|
||||
return false;
|
||||
|
||||
if (!sm5.is_small() || !sm7.is_small())
|
||||
return false;
|
||||
|
||||
smb5.swap(smb7);
|
||||
if (!boost::container::test::CheckEqualContainers(sm7_copy, sm7))
|
||||
return false;
|
||||
if (!boost::container::test::CheckEqualContainers(sm5_copy, sm5))
|
||||
return false;
|
||||
|
||||
if (!sm5.is_small() || !sm7.is_small())
|
||||
return false;
|
||||
}
|
||||
{
|
||||
//Both in dynamic memory
|
||||
sm5_t sm5;
|
||||
for(std::size_t i = 0, max = sm5.capacity()+1; i != max; ++i){
|
||||
sm5.push_back(int(i));
|
||||
}
|
||||
|
||||
sm7_t sm7;
|
||||
for(std::size_t i = 0, max = sm7.capacity()+1; i != max; ++i){
|
||||
sm7.push_back(int(i));
|
||||
}
|
||||
|
||||
sm5_t sm5_copy(sm5);
|
||||
sm7_t sm7_copy(sm7);
|
||||
smb_t& smb5 = sm5_copy;
|
||||
smb_t& smb7 = sm7_copy;
|
||||
|
||||
if (smb5.is_small() || smb7.is_small())
|
||||
return false;
|
||||
|
||||
smb5.swap(smb7);
|
||||
if (!boost::container::test::CheckEqualContainers(sm5_copy, sm7))
|
||||
return false;
|
||||
if (!boost::container::test::CheckEqualContainers(sm7_copy, sm5))
|
||||
return false;
|
||||
|
||||
if (smb5.is_small() || smb7.is_small())
|
||||
return false;
|
||||
|
||||
smb5.swap(smb7);
|
||||
if (!boost::container::test::CheckEqualContainers(sm7_copy, sm7))
|
||||
return false;
|
||||
if (!boost::container::test::CheckEqualContainers(sm5_copy, sm5))
|
||||
return false;
|
||||
|
||||
if (smb5.is_small() || smb7.is_small())
|
||||
return false;
|
||||
}
|
||||
{
|
||||
//sm7 in dynamic memory
|
||||
sm5_t sm5;
|
||||
for(std::size_t i = 0, max = sm5.capacity()-1; i != max; ++i){
|
||||
sm5.push_back(int(i));
|
||||
}
|
||||
|
||||
sm7_t sm7;
|
||||
for(std::size_t i = 0, max = sm7.capacity()+1; i != max; ++i){
|
||||
sm7.push_back(int(i));
|
||||
}
|
||||
|
||||
sm5_t sm5_copy(sm5);
|
||||
sm7_t sm7_copy(sm7);
|
||||
smb_t& smb5 = sm5_copy;
|
||||
smb_t& smb7 = sm7_copy;
|
||||
|
||||
if (!smb5.is_small() || smb7.is_small())
|
||||
return false;
|
||||
|
||||
//As small_vector_base is capacity-erased, will make an element-wise swap,
|
||||
//remaining smb7 elements won't fit in smb5's internal buffer so both will be dynamic
|
||||
smb5.swap(smb7);
|
||||
if (!boost::container::test::CheckEqualContainers(sm5_copy, sm7))
|
||||
return false;
|
||||
if (!boost::container::test::CheckEqualContainers(sm7_copy, sm5))
|
||||
return false;
|
||||
|
||||
if (smb5.is_small() || smb7.is_small())
|
||||
return false;
|
||||
|
||||
//Swap them again (both dynamic)
|
||||
smb5.swap(smb7);
|
||||
if (!boost::container::test::CheckEqualContainers(sm7_copy, sm7))
|
||||
return false;
|
||||
if (!boost::container::test::CheckEqualContainers(sm5_copy, sm5))
|
||||
return false;
|
||||
|
||||
if (smb5.is_small() || smb7.is_small())
|
||||
return false;
|
||||
|
||||
//Try again with one dynamic, but the reverse option
|
||||
//shrink to fit should free the dynamic buffer after clear
|
||||
//and both should be small again using the internal buffer
|
||||
sm5_copy.clear();
|
||||
sm5_copy.shrink_to_fit();
|
||||
sm7_copy.clear();
|
||||
sm7_copy.shrink_to_fit();
|
||||
|
||||
if (!smb5.is_small() || !smb7.is_small())
|
||||
return false;
|
||||
|
||||
sm5_copy = sm5;
|
||||
sm7_copy = sm7;
|
||||
|
||||
if (!smb5.is_small() || smb7.is_small())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -116,13 +250,28 @@ bool test_swap()
|
||||
if(v.size() != w_size || w.size() != v_size)
|
||||
return false;
|
||||
}
|
||||
{ //v bigger than static capacity, w enough capacity for static
|
||||
vec v;
|
||||
for (std::size_t i = 0, max = v.capacity() + 1; i != max; ++i) {
|
||||
v.push_back(int(i));
|
||||
}
|
||||
vec w;
|
||||
for (std::size_t i = 0, max = w.capacity() / 2; i != max; ++i) {
|
||||
w.push_back(int(i));
|
||||
}
|
||||
const std::size_t v_size = v.size();
|
||||
const std::size_t w_size = w.size();
|
||||
v.swap(w);
|
||||
if (v.size() != w_size || w.size() != v_size)
|
||||
return false;
|
||||
}
|
||||
{ //v & w smaller than static capacity
|
||||
vec v;
|
||||
for(std::size_t i = 0, max = v.capacity()-1; i != max; ++i){
|
||||
v.push_back(int(i));
|
||||
}
|
||||
vec w;
|
||||
for(std::size_t i = 0, max = v.capacity()/2; i != max; ++i){
|
||||
for(std::size_t i = 0, max = w.capacity()/2; i != max; ++i){
|
||||
w.push_back(int(i));
|
||||
}
|
||||
const std::size_t v_size = v.size();
|
||||
@@ -137,7 +286,7 @@ bool test_swap()
|
||||
v.push_back(int(i));
|
||||
}
|
||||
vec w;
|
||||
for(std::size_t i = 0, max = v.capacity()*2; i != max; ++i){
|
||||
for(std::size_t i = 0, max = w.capacity()*2; i != max; ++i){
|
||||
w.push_back(int(i));
|
||||
}
|
||||
const std::size_t v_size = v.size();
|
||||
@@ -146,6 +295,73 @@ bool test_swap()
|
||||
if(v.size() != w_size || w.size() != v_size)
|
||||
return false;
|
||||
}
|
||||
|
||||
//Now test internal buffer/dynamic buffer swapping
|
||||
{
|
||||
typedef boost::container::small_vector<int, 5> sm5_t;
|
||||
|
||||
{
|
||||
sm5_t sm5;
|
||||
for (std::size_t i = 0, max = sm5.capacity() - 1; i != max; ++i) {
|
||||
sm5.push_back(int(i));
|
||||
}
|
||||
|
||||
sm5_t sm5_copy(sm5);
|
||||
{
|
||||
sm5_t sm5_dyn(sm5);
|
||||
sm5_dyn.resize(sm5_dyn.capacity() + 1u);
|
||||
sm5_dyn.resize(sm5.size());
|
||||
|
||||
if (sm5_dyn != sm5 || sm5_dyn.is_small())
|
||||
return false;
|
||||
|
||||
//Swap derived small vector one static one dynamic
|
||||
sm5_copy.swap(sm5_dyn);
|
||||
|
||||
if (sm5_dyn != sm5)
|
||||
return false;
|
||||
|
||||
//Dynamic buffer should be transferred, the old dynamic should be small now
|
||||
if (sm5_copy.is_small() || !sm5_dyn.is_small())
|
||||
return false;
|
||||
|
||||
//Swap derived small vector one static one dynamic
|
||||
sm5_copy.swap(sm5_dyn);
|
||||
|
||||
if (sm5_dyn != sm5)
|
||||
return false;
|
||||
|
||||
//Dynamic buffer should be transferred, the old dynamic should be small now
|
||||
if (!sm5_copy.is_small() || sm5_dyn.is_small())
|
||||
return false;
|
||||
}
|
||||
{
|
||||
sm5_t sm5_int(sm5);
|
||||
if (sm5_int != sm5 || !sm5_int.is_small())
|
||||
return false;
|
||||
|
||||
//Swap derived small vector one static one dynamic
|
||||
sm5_copy.swap(sm5_int);
|
||||
|
||||
if (sm5_int != sm5)
|
||||
return false;
|
||||
|
||||
//No dynamic memory should be present as small capacity is enough
|
||||
if (!sm5_copy.is_small() || !sm5_int.is_small())
|
||||
return false;
|
||||
|
||||
//Swap derived small vector one static one dynamic
|
||||
sm5_copy.swap(sm5_int);
|
||||
|
||||
if (sm5_int != sm5)
|
||||
return false;
|
||||
|
||||
//No dynamic memory should be present as small capacity is enough
|
||||
if (!sm5_copy.is_small() || !sm5_int.is_small())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ using namespace boost::container;
|
||||
class recursive_vector
|
||||
{
|
||||
public:
|
||||
int id_;
|
||||
stable_vector<recursive_vector> vector_;
|
||||
stable_vector<recursive_vector>::iterator it_;
|
||||
stable_vector<recursive_vector>::const_iterator cit_;
|
||||
|
||||
@@ -91,7 +91,6 @@ class recursive_vector
|
||||
recursive_vector & operator=(const recursive_vector &x)
|
||||
{ this->vector_ = x.vector_; return *this; }
|
||||
|
||||
int id_;
|
||||
vector<recursive_vector> vector_;
|
||||
vector<recursive_vector>::iterator it_;
|
||||
vector<recursive_vector>::const_iterator cit_;
|
||||
@@ -226,11 +225,13 @@ bool test_span_conversion()
|
||||
|
||||
#endif //BOOST_VECTOR_TEST_HAS_SPAN
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
struct POD { int POD::*ptr; };
|
||||
BOOST_CONTAINER_STATIC_ASSERT_MSG
|
||||
( boost::container::dtl::is_pod<POD>::value
|
||||
, "POD test failed"
|
||||
);
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -409,7 +410,7 @@ int main()
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// POD types should not be 0-filled testing
|
||||
// POD types should not be 0-filled
|
||||
////////////////////////////////////
|
||||
#if !defined(_MSC_VER)
|
||||
// MSVC miscompiles value initialization of pointers to data members,
|
||||
|
||||
Reference in new issue
Block a user