From 69b882a14b3a99ebefda79029c4f72a985105cf3 Mon Sep 17 00:00:00 2001 From: LeonineKing1199 Date: Tue, 23 Nov 2021 11:10:03 -0800 Subject: [PATCH] Add defaulted copy assignment operators when supported --- test/objects/cxx11_allocator.hpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/test/objects/cxx11_allocator.hpp b/test/objects/cxx11_allocator.hpp index 3e5f11c8..8f3a7711 100644 --- a/test/objects/cxx11_allocator.hpp +++ b/test/objects/cxx11_allocator.hpp @@ -181,12 +181,9 @@ namespace test ~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_DEFAULTED_FUNCTIONS) + cxx11_allocator_base& operator=(cxx11_allocator_base const& x) = default; +#endif pointer address(reference r) { return pointer(&r); } @@ -272,11 +269,9 @@ namespace test cxx11_allocator(cxx11_allocator const& x) : cxx11_allocator_base(x) {} - cxx11_allocator& operator=(cxx11_allocator const& x) - { - cxx11_allocator_base::operator=(x); - return *this; - } +#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) + cxx11_allocator& operator=(cxx11_allocator const& x) = default; +#endif // When not propagating swap, allocators are always equal // to avoid undefined behaviour. @@ -321,11 +316,9 @@ namespace test cxx11_allocator(cxx11_allocator const& x) : cxx11_allocator_base(x) {} - cxx11_allocator& operator=(cxx11_allocator const& x) - { - cxx11_allocator_base::operator=(x); - return *this; - } +#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) + cxx11_allocator& operator=(cxx11_allocator const& x) = default; +#endif // When not propagating swap, allocators are always equal // to avoid undefined behaviour.