From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- libstdc++-v3/testsuite/20_util/tuple/48476.cc | 51 ++++++++++ .../tuple/comparison_operators/35480_neg.cc | 33 ++++++ .../tuple/comparison_operators/comparisons.cc | 49 +++++++++ libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc | 34 +++++++ libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc | 51 ++++++++++ libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc | 43 ++++++++ libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc | 27 +++++ .../testsuite/20_util/tuple/cons/assignment.cc | 52 ++++++++++ .../testsuite/20_util/tuple/cons/big_tuples.cc | 105 +++++++++++++++++++ .../testsuite/20_util/tuple/cons/constexpr.cc | 47 +++++++++ .../testsuite/20_util/tuple/cons/constructor.cc | 65 ++++++++++++ .../testsuite/20_util/tuple/cons/converting.cc | 37 +++++++ .../20_util/tuple/creation_functions/23978.cc | 45 +++++++++ .../20_util/tuple/creation_functions/48476.cc | 85 ++++++++++++++++ .../tuple/creation_functions/forward_as_tuple.cc | 72 +++++++++++++ .../20_util/tuple/creation_functions/make_tuple.cc | 37 +++++++ .../20_util/tuple/creation_functions/tie.cc | 42 ++++++++ .../20_util/tuple/creation_functions/tie2.cc | 38 +++++++ .../testsuite/20_util/tuple/element_access/get.cc | 44 ++++++++ libstdc++-v3/testsuite/20_util/tuple/moveable.cc | 42 ++++++++ libstdc++-v3/testsuite/20_util/tuple/moveable2.cc | 64 ++++++++++++ .../testsuite/20_util/tuple/requirements/dr801.cc | 52 ++++++++++ .../tuple/requirements/explicit_instantiation.cc | 24 +++++ libstdc++-v3/testsuite/20_util/tuple/swap.cc | 111 +++++++++++++++++++++ .../testsuite/20_util/tuple/tuple_element.cc | 37 +++++++ libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc | 38 +++++++ 26 files changed, 1325 insertions(+) create mode 100644 libstdc++-v3/testsuite/20_util/tuple/48476.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/moveable.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/moveable2.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/swap.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc (limited to 'libstdc++-v3/testsuite/20_util/tuple') diff --git a/libstdc++-v3/testsuite/20_util/tuple/48476.cc b/libstdc++-v3/testsuite/20_util/tuple/48476.cc new file mode 100644 index 000000000..efe0007a6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/48476.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +template + typename std::decay::type copy(T&& x) + { return std::forward(x); } + +// libstdc++/48476 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p(new int()), q, r; + + std::tuple&, int> t0(p, 23), t1(q, 0); + t1 = copy(t0); // shall be equivalent to + // q = p; std::get<1>(t1) = std::get<1>(t0); + VERIFY( q == p ); + + std::tuple&, char> t2(r, 0); + t2 = copy(t1); // shall be equivalent to + // r = q; std::get<1>(t2) = std::get<1>(t1); + VERIFY( r == q ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc new file mode 100644 index 000000000..613c27f8b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include + +// libstdc++/35480 +void test01() +{ + std::tuple t1( 1 ); + std::tuple t2( 1, 2 ); + if ( t1 < t2 ) {} // { dg-error "here" } + if ( t1 == t2 ) {} // { dg-error "here" } +} +// { dg-excess-errors "incomplete type" } diff --git a/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc new file mode 100644 index 000000000..c10fb1cbc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include + +using namespace std; + +bool test __attribute__((unused)) = true; + +#define TEST1(x) VERIFY( x == x && !(x != x) && x <= x && !(x < x) ) + +int +main() +{ + int i=0; + int j=0; + int k=2; + tuple a(0, 0, 0); + tuple b(0, 0, 1); + tuple c(i,j,k); + tuple d(c); + TEST1(a); + TEST1(b); + TEST1(c); + TEST1(d); + VERIFY(!(a > a) && !(b > b)); + VERIFY(a >= a && b >= b); + VERIFY(a < b && !(b < a) && a <= b && !(b <= a)); + VERIFY(b > a && !(a > b) && b >= a && !(a >= b)); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc new file mode 100644 index 000000000..6bd405c09 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include + +class A {}; +class B : public A {}; + +// PR libstdc++/41530 +void test01() +{ + std::tuple b; + std::tuple a1(b); + std::tuple a2(std::move(b)); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc new file mode 100644 index 000000000..dade58de8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +int x, y; + +std::tuple +foo1() +{ + std::pair blah(x, y); + return blah; +} + +std::tuple +foo2() +{ + const std::pair blah(x, y); + return blah; +} + +std::tuple +foo3() +{ + std::pair blah(x, y); + return std::tuple(std::move(blah)); +} + +std::tuple +foo4() +{ + const std::pair blah(x, y); + return std::tuple(std::move(blah)); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc new file mode 100644 index 000000000..863d78847 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +typedef std::tuple Tuple_1; +typedef std::tuple Tuple_2; +typedef std::tuple Tuple_3; + + Tuple_1 A_1() { return Tuple_1(); } +const Tuple_1 B_1() { return Tuple_1(); } + + Tuple_2 A_2() { return Tuple_2(); } +const Tuple_2 B_2() { return Tuple_2(); } + + Tuple_3 A_3() { return Tuple_3(); } +const Tuple_3 B_3() { return Tuple_3(); } + +Tuple_1 test_A_1(A_1()); +Tuple_1 test_B_1(B_1()); + +Tuple_2 test_A_2(A_2()); +Tuple_2 test_B_2(B_2()); + +Tuple_3 test_A_3(A_3()); +Tuple_3 test_B_3(B_3()); diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc new file mode 100644 index 000000000..b5e3604d2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +void f() +{ + int i = 0; + std::tuple t __attribute__((unused)) = std::forward_as_tuple(i, 0); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc new file mode 100644 index 000000000..111a398ff --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + tuple<> ta; + tuple<> tb; + ta = tb; + + tuple tc(1); + tuple td(0); + td = tc; + VERIFY(get<0>(td) == 1); + + int i=0; + tuple te(i); + te = tc; + VERIFY(i == 1); + + tuple tf(tc); + + get<0>(tc) = 2; + VERIFY(get<0>(tf) == 2); + tuple tg; + tg = tc; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc new file mode 100644 index 000000000..7bcb51771 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc @@ -0,0 +1,105 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include // for pair +#include + +using namespace std; + +// A simple class without conversions to check some things +struct foo +{ }; + +void +test_constructors() +{ + bool test __attribute__((unused)) = true; + + int x1=0,x2=0; + const int &z1=x1; + + // Test empty constructor + tuple<> ta __attribute__((unused)); + tuple tb; + // Test construction from values + tuple tc(x1,x2); + tuple td(x1,x2); + tuple te(z1); + x1=1; + x2=1; + VERIFY(get<0>(td) == 0 && get<1>(td) == 1 && get<0>(te) == 1); + + // Test identical tuple copy constructor + tuple tf(tc); + tuple tg(td); + tuple th(te); + // Test different tuple copy constructor + tuple ti(tc); + tuple tj(td); + // Test constructing from a pair + pair pair1(1,1); + const pair pair2(pair1); + tuple tl(pair1); + tuple tm(pair1); + tuple tn(pair2); + tuple to(pair2); +} + +int +main(void) +{ + //test construction + typedef tuple type1; + type1 a(0, 0, 0, 0, 0, 0, 0, 0, 0, 1); + type1 b(0, 0, 0, 0, 0, 0, 0, 0, 0, 2); + type1 c(a); + typedef tuple type2; + type2 d(0, 0, 0, 0, 0, 0, 0, 0, 0, 3); + type1 e(d); + typedef tuple type3; + // get + VERIFY(get<9>(a)==1 && get<9>(b)==2); + // comparisons + VERIFY(a==a && !(a!=a) && a<=a && a>=a && !(aa)); + VERIFY(!(a==b) && a!=b && a<=b && a=b) && !(a>b)); + //tie + { + int i = 0; + tie(ignore, ignore, ignore, ignore, ignore, ignore, ignore, ignore, + ignore, i) = a; + VERIFY(i == 1); + } + //test_assignment + a=d; + a=b; + //make_tuple + make_tuple(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + //tuple_size + VERIFY(tuple_size::value == 10); + //tuple_element + { + foo q1; + tuple_element<0,type3>::type q2(q1); + tuple_element<9,type3>::type q3(q1); + } +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr.cc new file mode 100644 index 000000000..b5eba73fd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr.cc @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test1; + test1.operator()>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator(), std::tuple>(); + // test2.operator(), std::pair>(); + // test2.operator(), std::tuple>(); + // test2.operator(), std::tuple>(); + + // test 3 + const int i1(129); + const int i2(6); + constexpr std::tuple p3(i1, i2); + + // test 4 + const int i3(415); + const int i4(550); + const int i5(6414); + constexpr std::tuple p4(i1, i2, i3, i4, i5); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc new file mode 100644 index 000000000..9871f4959 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include // for pair +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int x1=0,x2=0; + const int &z1=x1; + + // Test empty constructor + tuple<> ta __attribute__((unused)); + tuple tb; + // Test construction from values + tuple tc(x1,x2); + tuple td(x1,x2); + tuple te(z1); + x1=1; + x2=1; + VERIFY(get<0>(td) == 0 && get<1>(td) == 1 && get<0>(te) == 1); + + // Test identical tuple copy constructor + tuple tf(tc); + tuple tg(td); + tuple th(te); + // Test different tuple copy constructor + tuple ti(tc); + tuple tj(td); + //tuple tk(tc); + tuple tl(tc); + tuple tm(tl); + // Test constructing from a pair + pair pair1(1,1); + const pair pair2(pair1); + tuple tn(pair1); + tuple to(pair1); + tuple tp(pair2); + tuple tq(pair2); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc new file mode 100644 index 000000000..def1b521d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +// http://gcc.gnu.org/ml/libstdc++/2008-02/msg00047.html +std::tuple ts1; +std::tuple tu1(ts1); + +std::tuple ts2; +std::tuple tu2(ts2); + +std::tuple ts3; +std::tuple tu3(ts3); + +std::tuple tm2; +std::tuple tm2_(tm2); + +std::tuple tm3; +std::tuple tm3_(tm3); diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc new file mode 100644 index 000000000..7db57bc70 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include +#include + +using namespace std; + +// libstdc++/23978 +void test01() +{ + bool test __attribute__((unused)) = true; + + pair p(1, 2); + int x = 0; + int y = 0; + tie(x, y) = p; + VERIFY( x == 1 && y == 2 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc new file mode 100644 index 000000000..1607e4552 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +template + typename std::decay::type copy(T&& x) + { return std::forward(x); } + +template + void + check_tuple_cat(std::tuple t1, std::tuple t2) + { + bool test __attribute__((unused)) = true; + + typedef std::tuple concatenated; + + auto cat1 = std::tuple_cat( t1, t2 ); + auto cat2 = std::tuple_cat(copy(t1), t2 ); + auto cat3 = std::tuple_cat( t1, copy(t2)); + auto cat4 = std::tuple_cat(copy(t1), copy(t2)); + + static_assert( std::is_same::value, "" ); + static_assert( std::is_same::value, "" ); + static_assert( std::is_same::value, "" ); + static_assert( std::is_same::value, "" ); + + VERIFY( cat1 == cat2 ); + VERIFY( cat1 == cat3 ); + VERIFY( cat1 == cat4 ); + } + +// libstdc++/48476 +void test01() +{ + int i = 0; + std::tuple<> t0; + std::tuple t1(i); + std::tuple t2(i, 0); + std::tuple t3(i, 0, 0); + + check_tuple_cat(t0, t0); + check_tuple_cat(t0, t1); + check_tuple_cat(t0, t2); + check_tuple_cat(t0, t3); + + check_tuple_cat(t1, t0); + check_tuple_cat(t1, t1); + check_tuple_cat(t1, t2); + check_tuple_cat(t1, t3); + + check_tuple_cat(t2, t0); + check_tuple_cat(t2, t1); + check_tuple_cat(t2, t2); + check_tuple_cat(t2, t3); + + check_tuple_cat(t3, t0); + check_tuple_cat(t3, t1); + check_tuple_cat(t3, t2); + check_tuple_cat(t3, t3); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc new file mode 100644 index 000000000..bad4ad49c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-04-30 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::forward_as_tuple(); + + VERIFY( std::get<0>(std::forward_as_tuple(-1)) == -1 ); + VERIFY( (std::is_same>::value) ); + + const int i1 = 1; + const int i2 = 2; + const double d1 = 4.0; + auto t1 = std::forward_as_tuple(i1, i2, d1); + VERIFY( (std::is_same>::value) ); + VERIFY( std::get<0>(t1) == i1 ); + VERIFY( std::get<1>(t1) == i2 ); + VERIFY( std::get<2>(t1) == d1 ); + + typedef const int a_type1[3]; + a_type1 a1 = { -1, 1, 2 }; + auto t2 = std::forward_as_tuple(a1); + VERIFY( (std::is_same>::value) ); + VERIFY( std::get<0>(t2)[0] == a1[0] ); + VERIFY( std::get<0>(t2)[1] == a1[1] ); + VERIFY( std::get<0>(t2)[2] == a1[2] ); + + typedef int a_type2[2]; + a_type2 a2 = { 2, -2 }; + volatile int i4 = 1; + auto t3 = std::forward_as_tuple(a2, i4); + VERIFY( (std::is_same>::value) ); + VERIFY( std::get<0>(t3)[0] == a2[0] ); + VERIFY( std::get<0>(t3)[1] == a2[1] ); + VERIFY( std::get<1>(t3) == i4 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc new file mode 100644 index 000000000..7521111fa --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int i=0; + make_tuple(1,2,4.0); + make_tuple(ref(i)) = tuple(1); + VERIFY(i == 1); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc new file mode 100644 index 000000000..a76928979 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int x1 = 0; + int x2 = 0; + int y1 = 0; + int y2 = 0; + tuple ta(1,1); + tuple tc(x1,x2); + tie(y1,y2)=ta; + VERIFY(y1 == 1 && y2 == 1); + tie(y1,y2)=tc; + VERIFY(y1 == 0 && y2 == 0); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc new file mode 100644 index 000000000..538c3e8e1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include +#include + +int +main() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + int i; + string s; + + tie(i, ignore, s) = make_tuple(42, 3.14, "C++"); + VERIFY( i == 42 ); + VERIFY( s == "C++" ); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc b/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc new file mode 100644 index 000000000..1ec01cfca --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int j=1; + const int k=2; + tuple a(0,j,k); + const tuple b(1,j,k); + VERIFY(get<0>(a)==0 && get<1>(a)==1 && get<2>(a)==2); + get<0>(a)=3; + get<1>(a)=4; + VERIFY(get<0>(a)==3 && get<1>(a)==4); + VERIFY(j==4); + get<1>(b)=5; + VERIFY(get<0>(b)==1 && get<1>(b)==5 && get<2>(b)==2); + VERIFY(j==5); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/moveable.cc b/libstdc++-v3/testsuite/20_util/tuple/moveable.cc new file mode 100644 index 000000000..0fedd83ed --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/moveable.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on tuple. If the implementation changed +// this test may begin to fail. + +#include +#include +#include + +int main() +{ + bool test __attribute__((unused)) = true; + + std::tuple a(1, 2.0), b; + b = std::move(a); + VERIFY( std::get<0>(b) == 1 && std::get<1>(b) == 2.0 ); + VERIFY( std::get<0>(a) == 1 && std::get<1>(a) == 2.0 ); + + std::tuple c(std::move(b)); + VERIFY( std::get<0>(c) == 1 && std::get<1>(c) == 2.0 ); + VERIFY( std::get<0>(b) == 1 && std::get<1>(b) == 2.0 ); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc b/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc new file mode 100644 index 000000000..f08007421 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +struct MoveOnly +{ + MoveOnly () { } + + MoveOnly (MoveOnly&&) { } + + MoveOnly& operator=(MoveOnly&&) + { return *this; } + +private: + MoveOnly(MoveOnly const&); // = delete + MoveOnly& operator=(MoveOnly const&); // = delete +}; + +MoveOnly +make_move_only () +{ return MoveOnly(); } + +// http://gcc.gnu.org/ml/libstdc++/2008-02/msg00046.html +void test01() +{ + typedef std::tuple move_only_tuple; + + move_only_tuple t1(make_move_only()); + move_only_tuple t2(std::move(t1)); + move_only_tuple t3 = std::move(t2); + t1 = std::move(t3); + + typedef std::tuple move_only_tuple2; + + move_only_tuple2 t4(make_move_only(), make_move_only()); + move_only_tuple2 t5(std::move(t4)); + move_only_tuple2 t6 = std::move(t5); + t4 = std::move(t6); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc b/libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc new file mode 100644 index 000000000..fd21b9ee5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// DR 801, pair and tuple vs. "passed in registers" +void test_trivial() +{ + // PODType, TType, NType, SLType, LType, NLType, LTypeDerived + typedef std::tuple tuple_type; + // static_assert(std::is_literal_type::value, "! literal"); + static_assert(std::has_trivial_copy_constructor::value, + "! triv copy"); + static_assert(std::has_trivial_destructor::value, + "! triv destructor"); + // static_assert(std::is_standard_layout::value, + // "! standard layout"); + + // Negative + /* + static_assert(std::has_trivial_default_constructor::value, + "! triv default"); + static_assert(std::has_trivial_copy_assign::value, + "! triv assign"); + static_assert(std::is_trivial::value, "! triv"); + static_assert(std::is_pod::value, "! pod"); + */ +} + +int main() +{ + test_trivial(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..22b8f50f5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + + +#include + +template class std::tuple; diff --git a/libstdc++-v3/testsuite/20_util/tuple/swap.cc b/libstdc++-v3/testsuite/20_util/tuple/swap.cc new file mode 100644 index 000000000..613e9c2ff --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/swap.cc @@ -0,0 +1,111 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on tuple. If the implementation changed +// this test may begin to fail. + +#include +#include +#include + +struct MoveOnly +{ + explicit MoveOnly (int j) : i(j) { } + + MoveOnly (MoveOnly&& m) : i(m.i) { } + + MoveOnly& operator=(MoveOnly&& m) + { i = m.i; return *this; } + + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + + bool operator==(MoveOnly const& m) + { return i == m.i; } + + void swap(MoveOnly& m) + { std::swap(m.i, i); } + + int i; +}; + +void swap(MoveOnly& m1, MoveOnly& m2) +{ m1.swap(m2); } + +MoveOnly +make_move_only (int i) +{ return MoveOnly(i); } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::tuple<> t1, t2; + std::swap(t1, t2); + + VERIFY( t1 == t2 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::tuple t1(1), t2(2); + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + std::tuple t1(1, 1.0f), t2(2, 2.0f); + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); + VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f ); +} + +void test04() +{ + bool test __attribute__((unused)) = true; + + std::tuple + t1(1, 1.0f, make_move_only(1)), + t2(2, 2.0f, make_move_only(2)); + + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); + VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f ); + VERIFY( std::get<2>(t1) == make_move_only(2) + && std::get<2>(t2) == make_move_only(1) ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc b/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc new file mode 100644 index 000000000..9344ea082 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include + +using namespace std; + +struct foo +{ }; + +int +main() +{ + // As foo isn't constructible from anything else, this + // lets us check if type is returning foo when it should + foo q1; + tuple_element<0,tuple >::type q2(q1); + tuple_element<2,tuple >::type q3(q1); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc b/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc new file mode 100644 index 000000000..51f4a2db8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + VERIFY(tuple_size >::value == 0); + VERIFY(tuple_size >::value == 1); + VERIFY(tuple_size >::value == 1); + typedef tuple test_tuple1; + VERIFY(tuple_size::value == 3); + VERIFY(tuple_size > >::value == 1); +} -- cgit v1.2.3