Fix "-Wdeprecated-copy" warnings

This commit is contained in:
Ion Gaztañaga
2020-08-09 23:21:46 +02:00
parent 06417de498
commit 974e8e641a
8 changed files with 118 additions and 83 deletions

View File

@@ -98,6 +98,10 @@ class recursive_deque
{
public:
recursive_deque (const recursive_deque &x)
: deque_(x.deque_)
{}
recursive_deque & operator=(const recursive_deque &x)
{ this->deque_ = x.deque_; return *this; }
@@ -418,24 +422,20 @@ int main ()
typedef boost::container::deque<int> cont;
typedef cont::allocator_type allocator_type;
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
if (boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<allocator_type>::value &&
boost::has_trivial_destructor_after_move<pointer>::value) {
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
return 1;
}
BOOST_STATIC_ASSERT_MSG(!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<allocator_type>::value &&
boost::has_trivial_destructor_after_move<pointer>::value)
, "has_trivial_destructor_after_move(std::allocator) test failed");
}
// std::allocator
{
typedef boost::container::deque<int, std::allocator<int> > cont;
typedef cont::allocator_type allocator_type;
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
if (boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<allocator_type>::value &&
boost::has_trivial_destructor_after_move<pointer>::value) {
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
return 1;
}
BOOST_STATIC_ASSERT_MSG(!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<allocator_type>::value &&
boost::has_trivial_destructor_after_move<pointer>::value)
, "has_trivial_destructor_after_move(std::allocator) test failed");
}
return 0;

View File

@@ -54,6 +54,10 @@ public:
list<recursive_list>::reverse_iterator rit_;
list<recursive_list>::const_reverse_iterator crit_;
recursive_list(const recursive_list &o)
: list_(o.list_)
{}
recursive_list &operator=(const recursive_list &o)
{ list_ = o.list_; return *this; }
};
@@ -259,24 +263,22 @@ int main ()
typedef boost::container::list<int> cont;
typedef cont::allocator_type allocator_type;
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
if (boost::has_trivial_destructor_after_move<cont>::value !=
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<allocator_type>::value &&
boost::has_trivial_destructor_after_move<pointer>::value) {
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
return 1;
}
boost::has_trivial_destructor_after_move<pointer>::value)
, "has_trivial_destructor_after_move(default allocator) test failed");
}
// std::allocator
{
typedef boost::container::list<int, std::allocator<int> > cont;
typedef cont::allocator_type allocator_type;
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
if (boost::has_trivial_destructor_after_move<cont>::value !=
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<allocator_type>::value &&
boost::has_trivial_destructor_after_move<pointer>::value) {
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
return 1;
}
boost::has_trivial_destructor_after_move<pointer>::value)
, "has_trivial_destructor_after_move(std::allocator) test failed");
}
return 0;

View File

@@ -27,6 +27,13 @@ typedef std::pair<const test::movable_and_copyable_int, test::movable_and_copyab
class recursive_map
{
public:
recursive_map()
{}
recursive_map(const recursive_map &x)
: map_(x.map_)
{}
recursive_map & operator=(const recursive_map &x)
{ id_ = x.id_; map_ = x.map_; return *this; }
@@ -44,6 +51,13 @@ class recursive_map
class recursive_multimap
{
public:
recursive_multimap()
{}
recursive_multimap(const recursive_multimap &x)
: multimap_(x.multimap_)
{}
recursive_multimap & operator=(const recursive_multimap &x)
{ id_ = x.id_; multimap_ = x.multimap_; return *this; }
@@ -644,21 +658,19 @@ int main ()
{
typedef boost::container::map<int, int> cont;
typedef boost::container::dtl::tree<value_type, int, std::less<int>, void, void> tree;
if (boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value) {
std::cerr << "has_trivial_destructor_after_move(map, default allocator) test failed" << std::endl;
return 1;
}
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value)
, "has_trivial_destructor_after_move(map, default allocator) test failed");
}
// std::allocator
{
typedef boost::container::map<int, int, std::less<int>, std::allocator<value_type> > cont;
typedef boost::container::dtl::tree<value_type, int, std::less<int>, std::allocator<value_type>, void> tree;
if (boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value) {
std::cerr << "has_trivial_destructor_after_move(map, std::allocator) test failed" << std::endl;
return 1;
}
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value)
, "has_trivial_destructor_after_move(map, std::allocator) test failed");
}
//
// multimap
@@ -668,21 +680,19 @@ int main ()
// default allocator
typedef boost::container::multimap<int, int> cont;
typedef boost::container::dtl::tree<value_type, int, std::less<int>, void, void> tree;
if (boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value) {
std::cerr << "has_trivial_destructor_after_move(multimap, default allocator) test failed" << std::endl;
return 1;
}
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value)
, "has_trivial_destructor_after_move(multimap, default allocator) test failed");
}
// std::allocator
{
typedef boost::container::multimap<int, int, std::less<int>, std::allocator<value_type> > cont;
typedef boost::container::dtl::tree<value_type, int, std::less<int>, std::allocator<value_type>, void> tree;
if (boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value) {
std::cerr << "has_trivial_destructor_after_move(multimap, std::allocator) test failed" << std::endl;
return 1;
}
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value)
, "has_trivial_destructor_after_move(multimap, std::allocator) test failed");
}
}

View File

@@ -25,6 +25,13 @@ using namespace boost::container;
class recursive_set
{
public:
recursive_set()
{}
recursive_set(const recursive_set &x)
: set_(x.set_)
{}
recursive_set & operator=(const recursive_set &x)
{ id_ = x.id_; set_ = x.set_; return *this; }
@@ -43,6 +50,13 @@ public:
class recursive_multiset
{
public:
recursive_multiset()
{}
recursive_multiset(const recursive_multiset &x)
: multiset_(x.multiset_)
{}
recursive_multiset & operator=(const recursive_multiset &x)
{ id_ = x.id_; multiset_ = x.multiset_; return *this; }
@@ -611,41 +625,37 @@ int main ()
{
typedef boost::container::set<int> cont;
typedef boost::container::dtl::tree<int, void, std::less<int>, void, void> tree;
if (boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value) {
std::cerr << "has_trivial_destructor_after_move(set, default allocator) test failed" << std::endl;
return 1;
}
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value)
, "has_trivial_destructor_after_move(set, default allocator) test failed");
}
// set, std::allocator
{
typedef boost::container::set<int, std::less<int>, std::allocator<int> > cont;
typedef boost::container::dtl::tree<int, void, std::less<int>, std::allocator<int>, void> tree;
if (boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value) {
std::cerr << "has_trivial_destructor_after_move(set, std::allocator) test failed" << std::endl;
return 1;
}
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value)
, "has_trivial_destructor_after_move(set, std::allocator) test failed");
}
// multiset, default allocator
{
typedef boost::container::multiset<int> cont;
typedef boost::container::dtl::tree<int, void, std::less<int>, void, void> tree;
if (boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value) {
std::cerr << "has_trivial_destructor_after_move(multiset, default allocator) test failed" << std::endl;
return 1;
}
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value)
, "has_trivial_destructor_after_move(multiset, default allocator) test failed");
}
// multiset, std::allocator
{
typedef boost::container::multiset<int, std::less<int>, std::allocator<int> > cont;
typedef boost::container::dtl::tree<int, void, std::less<int>, std::allocator<int>, void> tree;
if (boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value) {
std::cerr << "has_trivial_destructor_after_move(multiset, std::allocator) test failed" << std::endl;
return 1;
}
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<tree>::value)
, "has_trivial_destructor_after_move(multiset, std::allocator) test failed");
}
return 0;

View File

@@ -30,6 +30,10 @@ public:
recursive_slist &operator=(const recursive_slist &o)
{ slist_ = o.slist_; return *this; }
recursive_slist (const recursive_slist &o)
: slist_(o.slist_)
{}
};
void recursive_slist_test()//Test for recursive types
@@ -262,24 +266,22 @@ int main ()
typedef boost::container::slist<int> cont;
typedef cont::allocator_type allocator_type;
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
if (boost::has_trivial_destructor_after_move<cont>::value !=
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<allocator_type>::value &&
boost::has_trivial_destructor_after_move<pointer>::value) {
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
return 1;
}
boost::has_trivial_destructor_after_move<pointer>::value)
, "has_trivial_destructor_after_move(default allocator) test failed");
}
// std::allocator
{
typedef boost::container::slist<int, std::allocator<int> > cont;
typedef cont::allocator_type allocator_type;
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
if (boost::has_trivial_destructor_after_move<cont>::value !=
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<allocator_type>::value &&
boost::has_trivial_destructor_after_move<pointer>::value) {
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
return 1;
}
boost::has_trivial_destructor_after_move<pointer>::value)
, "has_trivial_destructor_after_move(std::allocator) test failed");
}
return 0;

View File

@@ -35,6 +35,10 @@ class recursive_vector
stable_vector<recursive_vector>::reverse_iterator rit_;
stable_vector<recursive_vector>::const_reverse_iterator crit_;
recursive_vector (const recursive_vector &o)
: vector_(o.vector_)
{}
recursive_vector &operator=(const recursive_vector &o)
{ vector_ = o.vector_; return *this; }
};
@@ -200,24 +204,22 @@ int main()
typedef boost::container::stable_vector<int> cont;
typedef cont::allocator_type allocator_type;
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
if (boost::has_trivial_destructor_after_move<cont>::value !=
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<allocator_type>::value &&
boost::has_trivial_destructor_after_move<pointer>::value) {
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
return 1;
}
boost::has_trivial_destructor_after_move<pointer>::value)
, "has_trivial_destructor_after_move(default allocator) test failed");
}
// std::allocator
{
typedef boost::container::stable_vector<int, std::allocator<int> > cont;
typedef cont::allocator_type allocator_type;
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
if (boost::has_trivial_destructor_after_move<cont>::value !=
BOOST_STATIC_ASSERT_MSG(
!(boost::has_trivial_destructor_after_move<cont>::value !=
boost::has_trivial_destructor_after_move<allocator_type>::value &&
boost::has_trivial_destructor_after_move<pointer>::value) {
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
return 1;
}
boost::has_trivial_destructor_after_move<pointer>::value)
, "has_trivial_destructor_after_move(std::allocator) test failed");
}
return 0;

View File

@@ -48,11 +48,12 @@ class value_nc
public:
explicit value_nc(int a = 0) : aa(a) {}
~value_nc() {}
value_nc & operator=(int a){ aa = a; return *this; }
bool operator==(value_nc const& v) const { return aa == v.aa; }
bool operator<(value_nc const& v) const { return aa < v.aa; }
private:
value_nc(value_nc const&) {}
value_nc & operator=(value_ndc const&) { return *this; }
value_nc & operator=(value_nc const&) { return *this; }
int aa;
};
@@ -66,6 +67,7 @@ public:
counting_value(BOOST_RV_REF(counting_value) p) : aa(p.aa), bb(p.bb) { p.aa = 0; p.bb = 0; ++c(); } // Move constructor
counting_value& operator=(BOOST_RV_REF(counting_value) p) { aa = p.aa; p.aa = 0; bb = p.bb; p.bb = 0; return *this; } // Move assignment
counting_value& operator=(BOOST_COPY_ASSIGN_REF(counting_value) p) { aa = p.aa; bb = p.bb; return *this; } // Copy assignment
counting_value& operator=(int a) { aa =a; return *this; } // Copy assignment
~counting_value() { --c(); }
bool operator==(counting_value const& v) const { return aa == v.aa && bb == v.bb; }
bool operator<(counting_value const& v) const { return aa < v.aa || ( aa == v.aa && bb < v.bb ); }
@@ -94,6 +96,9 @@ class shptr_value
typedef boost::shared_ptr<int> Ptr;
public:
explicit shptr_value(int a = 0) : m_ptr(new int(a)) {}
shptr_value & operator=(int a)
{ m_ptr.reset(new int(a)); return *this; }
bool operator==(shptr_value const& v) const { return *m_ptr == *(v.m_ptr); }
bool operator<(shptr_value const& v) const { return *m_ptr < *(v.m_ptr); }
private:

View File

@@ -82,6 +82,10 @@ bool test_smart_ref_type()
class recursive_vector
{
public:
recursive_vector (const recursive_vector &x)
: vector_(x.vector_)
{}
recursive_vector & operator=(const recursive_vector &x)
{ this->vector_ = x.vector_; return *this; }