1 // Copyright (C) 2017 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::pointer_traits
<T
>::template rebind
<U
>;
29 template<typename U
> using rebind
= U
*;
32 static_assert(is_same
<Rebind
<HasRebind
<int>, long>,
34 "nested alias template is used");
36 template<typename T
> struct NoRebind0
{ };
38 static_assert(is_same
<Rebind
<NoRebind0
<int>, long>,
39 NoRebind0
<long>>::value
,
40 "first template argument is replaced");
42 template<typename T
, typename
> struct NoRebind1
{ };
44 static_assert(is_same
<Rebind
<NoRebind1
<int, void>, long>,
45 NoRebind1
<long, void>>::value
,
46 "first template argument is replaced");
48 template<typename T
, typename
, typename
> struct NoRebind2
{ };
50 static_assert(is_same
<Rebind
<NoRebind2
<int, void, void>, long>,
51 NoRebind2
<long, void, void>>::value
,
52 "first template argument is replaced");
54 template<typename T
, typename
...> struct NoRebindN
{ };
56 static_assert(is_same
<Rebind
<NoRebindN
<int>, long>,
57 NoRebindN
<long>>::value
,
58 "first template argument is replaced");
59 static_assert(is_same
<Rebind
<NoRebindN
<int, void>, long>,
60 NoRebindN
<long, void>>::value
,
61 "first template argument is replaced");
63 template<typename T
, int = 0>
65 using element_type
= T
;
67 // PR libstdc++/72793 specialization of pointer_traits is still well-formed:
68 std::pointer_traits
<CannotRebind
<int>>::element_type e
;