1 // { dg-do compile { target c++11 } }
2 // { dg-skip-if "argument_type removed for C++20" { c++2a } }
4 // Copyright (C) 2011-2024 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
22 #include <type_traits>
28 typedef int argument_type
;
33 typedef float first_argument_type
;
38 typedef char second_argument_type
;
41 struct S01
: S0
, S1
{ };
42 struct S02
: S0
, S2
{ };
43 struct S12
: S1
, S2
{ };
45 struct S012
: S0
, S1
, S2
{ };
48 using std::false_type
;
51 _GLIBCXX_HAS_NESTED_TYPE(argument_type
)
52 _GLIBCXX_HAS_NESTED_TYPE(first_argument_type
)
53 _GLIBCXX_HAS_NESTED_TYPE(second_argument_type
)
56 struct has_arg_type
: __has_argument_type
<T
>
60 struct has_1st_arg_type
: __has_first_argument_type
<T
>
64 struct has_2nd_arg_type
: __has_second_argument_type
<T
>
67 template<typename T
, bool = has_arg_type
<T
>::value
>
70 static_assert( !has_arg_type
<std::reference_wrapper
<T
>>::value
,
71 "reference_wrapper has no nested argument_type");
75 struct test_arg_type
<T
, true>
77 typedef std::reference_wrapper
<T
> ref
;
79 static_assert( has_arg_type
<ref
>::value
,
80 "reference_wrapper has nested argument_type");
83 std::is_same
< typename
T::argument_type
,
84 typename
ref::argument_type
>::value
,
85 "reference_wrapper has the correct argument_type");
89 bool = has_1st_arg_type
<T
>::value
&& has_2nd_arg_type
<T
>::value
>
90 struct test_1st_2nd_arg_types
92 typedef std::reference_wrapper
<T
> ref
;
94 static_assert( !has_1st_arg_type
<ref
>::value
,
95 "reference_wrapper has no nested first_argument_type");
97 static_assert( !has_2nd_arg_type
<ref
>::value
,
98 "reference_wrapper has no nested second_argument_type");
102 struct test_1st_2nd_arg_types
<T
, true>
104 typedef std::reference_wrapper
<T
> ref
;
106 static_assert( has_1st_arg_type
<ref
>::value
,
107 "reference_wrapper has nested first_argument_type");
109 static_assert( has_2nd_arg_type
<ref
>::value
,
110 "reference_wrapper has nested second_argument_type");
113 std::is_same
< typename
T::first_argument_type
,
114 typename
ref::first_argument_type
>::value
,
115 "reference_wrapper has correct first_argument_type");
118 std::is_same
< typename
T::second_argument_type
,
119 typename
ref::second_argument_type
>::value
,
120 "reference_wrapper has correct second_argument_type");
127 test_arg_type
<T
> t
__attribute__((unused
));
128 test_arg_type
<const T
> tc
__attribute__((unused
));
129 test_arg_type
<volatile T
> tv
__attribute__((unused
));
130 test_arg_type
<const volatile T
> tcv
__attribute__((unused
));
131 test_1st_2nd_arg_types
<T
> t12
__attribute__((unused
));
132 test_1st_2nd_arg_types
<const T
> t12c
__attribute__((unused
));
133 test_1st_2nd_arg_types
<volatile T
> t12v
__attribute__((unused
));
134 test_1st_2nd_arg_types
<const volatile T
> t12cv
__attribute__((unused
));