diff --git a/libstdc++-v3/include/debug/safe_container.h b/libstdc++-v3/include/debug/safe_container.h index d9636c29e9b..b06c33dac7e 100644 --- a/libstdc++-v3/include/debug/safe_container.h +++ b/libstdc++-v3/include/debug/safe_container.h @@ -57,7 +57,12 @@ namespace __gnu_debug _Safe_container(const _Safe_container&) = default; _Safe_container(_Safe_container&&) = default; - _Safe_container(_Safe_container&& __x, const _Alloc& __a) + private: + _Safe_container(_Safe_container&& __x, const _Alloc& __a, std::true_type) + : _Safe_container() + { _Base::_M_swap(__x); } + + _Safe_container(_Safe_container&& __x, const _Alloc& __a, std::false_type) : _Safe_container() { if (__x._M_cont().get_allocator() == __a) @@ -65,6 +70,12 @@ namespace __gnu_debug else __x._M_invalidate_all(); } + + protected: + _Safe_container(_Safe_container&& __x, const _Alloc& __a) + : _Safe_container(std::move(__x), __a, + typename std::allocator_traits<_Alloc>::is_always_equal{}) + { } #endif public: