]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/allocator_traits/members/rebind_alloc.cc
1 // Copyright (C) 2017-2020 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 compile { target c++11 } }
24 template<typename T
, typename U
>
25 using Rebind
= typename
std::allocator_traits
<T
>::template rebind_alloc
<U
>;
30 template<typename U
> struct rebind
{ using other
= std::allocator
<U
>; };
33 static_assert(is_same
<Rebind
<HasRebind
<int>, long>,
34 std::allocator
<long>>::value
,
35 "nested alias template is used");
42 static_assert(is_same
<Rebind
<NoRebind0
<int>, long>,
43 NoRebind0
<long>>::value
,
44 "first template argument is replaced");
46 template<typename T
, typename
>
51 static_assert(is_same
<Rebind
<NoRebind1
<int, void>, long>,
52 NoRebind1
<long, void>>::value
,
53 "first template argument is replaced");
55 template<typename T
, typename
, typename
>
60 static_assert(is_same
<Rebind
<NoRebind2
<int, void, void>, long>,
61 NoRebind2
<long, void, void>>::value
,
62 "first template argument is replaced");
64 template<typename T
, typename
...>
69 static_assert(is_same
<Rebind
<NoRebindN
<int>, long>,
70 NoRebindN
<long>>::value
,
71 "first template argument is replaced");
72 static_assert(is_same
<Rebind
<NoRebindN
<int, void>, long>,
73 NoRebindN
<long, void>>::value
,
74 "first template argument is replaced");
76 template<typename T
, int = 0>
80 // PR libstdc++/72792 specialization of allocator_traits is still well-formed:
81 std::allocator_traits
<CannotRebind
<int>>::value_type v
;