]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc
Use effective-target instead of -std options
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / tuple / creation_functions / forward_as_tuple.cc
CommitLineData
52066eae 1// { dg-do run { target c++11 } }
5e108459
PC
2
3// 2010-04-30 Paolo Carlini <paolo.carlini@oracle.com>
4//
818ab71a 5// Copyright (C) 2010-2016 Free Software Foundation, Inc.
5e108459
PC
6//
7// This file is part of the GNU ISO C++ Library. This library is free
8// software; you can redistribute it and/or modify it under the
9// terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 3, or (at your option)
11// any later version.
12
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17
18// You should have received a copy of the GNU General Public License along
19// with this library; see the file COPYING3. If not see
20// <http://www.gnu.org/licenses/>.
21
22// Tuple
23
24#include <tuple>
25#include <type_traits>
26#include <testsuite_hooks.h>
27
28void
29test01()
30{
31 bool test __attribute__((unused)) = true;
32
00e9a944 33 std::forward_as_tuple();
5e108459 34
00e9a944
PC
35 VERIFY( std::get<0>(std::forward_as_tuple(-1)) == -1 );
36 VERIFY( (std::is_same<decltype(std::forward_as_tuple(-1)),
5e108459
PC
37 std::tuple<int&&>>::value) );
38
39 const int i1 = 1;
40 const int i2 = 2;
41 const double d1 = 4.0;
00e9a944 42 auto t1 = std::forward_as_tuple(i1, i2, d1);
5e108459
PC
43 VERIFY( (std::is_same<decltype(t1), std::tuple<const int&,
44 const int&, const double&>>::value) );
45 VERIFY( std::get<0>(t1) == i1 );
46 VERIFY( std::get<1>(t1) == i2 );
47 VERIFY( std::get<2>(t1) == d1 );
48
49 typedef const int a_type1[3];
50 a_type1 a1 = { -1, 1, 2 };
00e9a944 51 auto t2 = std::forward_as_tuple(a1);
5e108459
PC
52 VERIFY( (std::is_same<decltype(t2), std::tuple<a_type1&>>::value) );
53 VERIFY( std::get<0>(t2)[0] == a1[0] );
54 VERIFY( std::get<0>(t2)[1] == a1[1] );
55 VERIFY( std::get<0>(t2)[2] == a1[2] );
56
57 typedef int a_type2[2];
58 a_type2 a2 = { 2, -2 };
59 volatile int i4 = 1;
00e9a944 60 auto t3 = std::forward_as_tuple(a2, i4);
5e108459
PC
61 VERIFY( (std::is_same<decltype(t3), std::tuple<a_type2&,
62 volatile int&>>::value) );
63 VERIFY( std::get<0>(t3)[0] == a2[0] );
64 VERIFY( std::get<0>(t3)[1] == a2[1] );
65 VERIFY( std::get<1>(t3) == i4 );
66}
67
68int main()
69{
70 test01();
71 return 0;
72}