]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/lwg2788.cc
f06ab40b99fb40b1928b5c258faa5130a5d8b9bc
1 // { dg-do run { target c++11 } }
2 // { dg-require-effective-target cxx11_abi }
4 // 2019-05-27 Nina Dinka Ranns <dinka.ranns@gmail.com>
6 // Copyright (C) 2015-2024 Free Software Foundation, Inc.
8 // This file is part of the GNU ISO C++ Library. This library is free
9 // software; you can redistribute it and/or modify it under the
10 // terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 3, or (at your option)
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License along
20 // with this library; see the file COPYING3. If not see
21 // <http://www.gnu.org/licenses/>.
24 #include <testsuite_hooks.h>
27 using traits
= std::char_traits
<C
>;
28 int constructCount
= 0;
30 static void resetCounter()
38 typedef Tp value_type
;
39 using size_type
= unsigned;
41 TestAllocator() noexcept
{ constructCount
++; }
44 TestAllocator(const TestAllocator
<T
>&) {}
46 Tp
*allocate(std::size_t n
)
47 { return std::allocator
<Tp
>().allocate(n
); }
49 void deallocate(Tp
*p
, std::size_t n
)
50 { std::allocator
<Tp
>().deallocate(p
, n
); }
54 template <class T
, class U
>
55 bool operator==(const TestAllocator
<T
>&, const TestAllocator
<U
>&)
57 template <class T
, class U
>
58 bool operator!=(const TestAllocator
<T
>&, const TestAllocator
<U
>&)
63 typedef TestAllocator
<C
> alloc_type
;
64 typedef std::basic_string
<C
, traits
, alloc_type
> test_type
;
65 test_type v1
{alloc_type()};
66 std::wstring v2
{L
"some_content"};
69 v1
.assign(v2
.begin(),v2
.end());
70 VERIFY( constructCount
== 0);
72 v1
.append(v2
.begin(),v2
.end());
73 VERIFY( constructCount
== 0);
75 v1
.insert(v1
.begin(),v1
.begin(),v1
.end());
76 VERIFY( constructCount
== 0);
78 v1
.replace(v1
.begin(),v1
.end(),v1
.begin(),v1
.end());
79 VERIFY( constructCount
== 0);