1 // Copyright (C) 2016-2025 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target c++11 } }
21 #include <testsuite_hooks.h>
27 using size_type
= unsigned;
30 : moved_to(false), moved_from(false) { }
33 mv_allocator(const mv_allocator
<U
> & a
)
34 : moved_to(a
.moved_to
), moved_from(a
.moved_from
) { }
36 mv_allocator(const mv_allocator
&) = default;
38 mv_allocator(mv_allocator
&& a
) noexcept
: moved_to(true)
43 T
* allocate(unsigned n
) { return std::allocator
<T
>{}.allocate(n
); }
44 void deallocate(T
* p
, unsigned n
) { std::allocator
<T
>{}.deallocate(p
, n
); }
50 template<typename T
, typename U
>
52 operator==(const mv_allocator
<T
>&, const mv_allocator
<U
>&) { return true; }
54 template<typename T
, typename U
>
56 operator!=(const mv_allocator
<T
>&, const mv_allocator
<U
>&) { return false; }
61 std::set
<int, std::less
<int>, mv_allocator
<int>> s
;
62 auto t
= std::move(s
);
63 VERIFY( s
.get_allocator().moved_from
);
64 VERIFY( t
.get_allocator().moved_to
);