mirror of
https://github.com/boostorg/unordered.git
synced 2025-05-12 05:51:44 +00:00
Fix warning about using implicitly defined copy constructor/assignment by completing the Rule of 5 for test allocator
This commit is contained in:
parent
c8abaf32ee
commit
e29f762116
@ -13,7 +13,14 @@
|
|||||||
#include "../helpers/fwd.hpp"
|
#include "../helpers/fwd.hpp"
|
||||||
#include "../helpers/memory.hpp"
|
#include "../helpers/memory.hpp"
|
||||||
|
|
||||||
namespace test {
|
#if defined(BOOST_NO_CXX11_NOEXCEPT)
|
||||||
|
#define BOOST_UNORDERED_NOEXCEPT
|
||||||
|
#else
|
||||||
|
#define BOOST_UNORDERED_NOEXCEPT noexcept
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace test
|
||||||
|
{
|
||||||
struct allocator_false
|
struct allocator_false
|
||||||
{
|
{
|
||||||
enum
|
enum
|
||||||
@ -178,8 +185,37 @@ namespace test {
|
|||||||
detail::tracker.allocator_ref();
|
detail::tracker.allocator_ref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
|
cxx11_allocator_base(cxx11_allocator_base&& x) BOOST_UNORDERED_NOEXCEPT
|
||||||
|
{
|
||||||
|
tag_ = x.tag_;
|
||||||
|
selected_ = x.selected_;
|
||||||
|
|
||||||
|
x.tag_ = -1;
|
||||||
|
x.selected_ = -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
~cxx11_allocator_base() { detail::tracker.allocator_unref(); }
|
~cxx11_allocator_base() { detail::tracker.allocator_unref(); }
|
||||||
|
|
||||||
|
cxx11_allocator_base& operator=(cxx11_allocator_base const& x)
|
||||||
|
{
|
||||||
|
tag_ = x.tag_;
|
||||||
|
selected_ = x.selected_;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
|
cxx11_allocator_base& operator=(
|
||||||
|
cxx11_allocator_base&& x) BOOST_UNORDERED_NOEXCEPT
|
||||||
|
{
|
||||||
|
tag_ = x.tag_;
|
||||||
|
selected_ = x.selected_;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pointer address(reference r) { return pointer(&r); }
|
pointer address(reference r) { return pointer(&r); }
|
||||||
|
|
||||||
const_pointer address(const_reference r) { return const_pointer(&r); }
|
const_pointer address(const_reference r) { return const_pointer(&r); }
|
||||||
@ -264,6 +300,20 @@ namespace test {
|
|||||||
|
|
||||||
cxx11_allocator(cxx11_allocator const& x) : cxx11_allocator_base<T>(x) {}
|
cxx11_allocator(cxx11_allocator const& x) : cxx11_allocator_base<T>(x) {}
|
||||||
|
|
||||||
|
cxx11_allocator& operator=(cxx11_allocator const& x)
|
||||||
|
{
|
||||||
|
cxx11_allocator_base<T>::operator=(x);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
|
cxx11_allocator& operator=(cxx11_allocator&& x) BOOST_UNORDERED_NOEXCEPT
|
||||||
|
{
|
||||||
|
cxx11_allocator_base<T>::operator=(static_cast<cxx11_allocator&&>(x));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// When not propagating swap, allocators are always equal
|
// When not propagating swap, allocators are always equal
|
||||||
// to avoid undefined behaviour.
|
// to avoid undefined behaviour.
|
||||||
bool operator==(cxx11_allocator const& x) const
|
bool operator==(cxx11_allocator const& x) const
|
||||||
@ -307,6 +357,20 @@ namespace test {
|
|||||||
|
|
||||||
cxx11_allocator(cxx11_allocator const& x) : cxx11_allocator_base<T>(x) {}
|
cxx11_allocator(cxx11_allocator const& x) : cxx11_allocator_base<T>(x) {}
|
||||||
|
|
||||||
|
cxx11_allocator& operator=(cxx11_allocator const& x)
|
||||||
|
{
|
||||||
|
cxx11_allocator_base<T>::operator=(x);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
|
cxx11_allocator& operator=(cxx11_allocator&& x) BOOST_UNORDERED_NOEXCEPT
|
||||||
|
{
|
||||||
|
cxx11_allocator_base<T>::operator=(static_cast<cxx11_allocator&&>(x));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// When not propagating swap, allocators are always equal
|
// When not propagating swap, allocators are always equal
|
||||||
// to avoid undefined behaviour.
|
// to avoid undefined behaviour.
|
||||||
bool operator==(cxx11_allocator const& x) const
|
bool operator==(cxx11_allocator const& x) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user