]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/87749.cc
1 // Copyright (C) 2018-2019 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 } }
23 #include <testsuite_hooks.h>
32 #if !_GLIBCXX_USE_CXX11_ABI
33 using size_type
= unsigned long;
34 using difference_type
= long;
36 using const_reference
= T
&;
38 using const_pointer
= const T
*;
40 struct rebind
{ using other
= alloc
<U
>; };
43 int not_empty
= 0; // this makes is_always_equal false
47 alloc(const alloc
<U
>&) { }
49 T
* allocate(unsigned long n
)
52 throw std::bad_alloc();
53 return std::allocator
<T
>().allocate(n
);
56 void deallocate(T
* p
, unsigned long n
)
58 std::allocator
<T
>().deallocate(p
, n
);
62 template<typename T
, typename U
>
63 bool operator==(const alloc
<T
>&, const alloc
<U
>&) { return true; }
65 template<typename T
, typename U
>
66 bool operator!=(const alloc
<T
>&, const alloc
<U
>&) { return false; }
70 using string
= std::basic_string
<char, std::char_traits
<char>, alloc
<char>>;
72 string s
= "PR libstdc++/87749 a string that is longer than a short string";
73 const auto ptr
= s
.c_str();
76 ss
= std::move(s
); // allocators are equal, should not allocate new storage
77 VERIFY( ss
.c_str() == ptr
);