]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc
1 // { dg-do compile { target c++11 } }
3 // Copyright (C) 2011-2022 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 // NOTE: This makes use of the fact that we know how moveable
22 // is implemented on pair, and also vector. If the implementation
23 // changes this test may begin to fail.
32 typedef std::tuple
<int, float> tuple_type
;
33 constexpr tuple_type p1
__attribute__((unused
))
34 = std::make_tuple(22, 22.222);
38 typedef std::tuple
<int, float, int> tuple_type
;
39 constexpr tuple_type p1
__attribute__((unused
))
40 = std::make_tuple(22, 22.222, 77799);
46 test_forward_as_tuple()
50 static float f(22.222);
51 typedef std::tuple
<int&, float&&> tuple_type
;
52 constexpr tuple_type p1
__attribute__((unused
))
53 = std::forward_as_tuple(i
, std::move(f
));
58 static float f(22.222);
61 typedef std::tuple
<int&, float&, int&&> tuple_type
;
62 constexpr tuple_type p1
__attribute__((unused
))
63 = std::forward_as_tuple(i
, f
, std::move(ii
));
73 static float f(22.222);
74 typedef std::tuple
<int&, float&> tuple_type
;
75 constexpr tuple_type p1
__attribute__((unused
))
81 static float f(22.222);
82 static const int ii(77799);
84 typedef std::tuple
<int&, float&, const int&> tuple_type
;
85 constexpr tuple_type p1
__attribute__((unused
))
95 typedef std::tuple
<int, float> tuple_type
;
96 constexpr tuple_type t1
{ 55, 77.77 };
97 constexpr auto var
__attribute__((unused
))
102 typedef std::tuple
<int, float, int> tuple_type
;
103 constexpr tuple_type t1
{ 55, 77.77, 99 };
104 constexpr auto var
__attribute__((unused
))
113 typedef std::tuple
<int, float> tuple_type1
;
114 typedef std::tuple
<int, int, float> tuple_type2
;
116 constexpr tuple_type1 t1
{ 55, 77.77 };
117 constexpr tuple_type2 t2
{ 55, 99, 77.77 };
118 constexpr auto cat1
__attribute__((unused
)) = std::tuple_cat(t1
, t2
);
124 constexpr int zero_from_anything(T
)
131 // ignore, see LWG 2773
135 constexpr auto ign1
__attribute__((unused
)) = std::ignore
;
136 constexpr auto ign2
__attribute__((unused
)) = std::make_tuple(std::ignore
);
137 constexpr int ign3
__attribute__((unused
)) = zero_from_anything(std::ignore
);
144 test_forward_as_tuple();