]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/allocator/71964.cc
1 // Copyright (C) 2016-2018 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 } }
19 // COW strings don't support C++11 allocators:
20 // { dg-require-effective-target cxx11-abi }
23 #include <testsuite_hooks.h>
29 using size_type
= unsigned;
32 : moved_to(false), moved_from(false) { }
35 mv_allocator(const mv_allocator
<U
> & a
)
36 : moved_to(a
.moved_to
), moved_from(a
.moved_from
) { }
38 mv_allocator(const mv_allocator
&) = default;
40 mv_allocator(mv_allocator
&& a
) noexcept
: moved_to(true)
45 T
* allocate(unsigned n
) { return std::allocator
<T
>{}.allcoate(n
); }
46 void deallocate(T
* p
, unsigned n
) { std::allocator
<T
>{}.deallocate(p
, n
); }
52 template<typename T
, typename U
>
54 operator==(const mv_allocator
<T
>&, const mv_allocator
<U
>&) { return true; }
56 template<typename T
, typename U
>
58 operator!=(const mv_allocator
<T
>&, const mv_allocator
<U
>&) { return false; }
63 std::basic_string
<char, std::char_traits
<char>, mv_allocator
<char>> s
;
64 auto t
= std::move(s
);
65 VERIFY( s
.get_allocator().moved_from
);
66 VERIFY( t
.get_allocator().moved_to
);