diff options
Diffstat (limited to 'gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons')
12 files changed, 765 insertions, 0 deletions
diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc new file mode 100644 index 000000000..625a273c3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 +// <http://www.gnu.org/licenses/>. + +// Tuple + +#include <tuple> + +class A {}; +class B : public A {}; + +// PR libstdc++/41530 +void test01() +{ + std::tuple<B*> b; + std::tuple<A*> a1(b); + std::tuple<A*> a2(std::move(b)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc new file mode 100644 index 000000000..d269f606a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <tuple> + +int x, y; + +std::tuple<int&, int&> +foo1() +{ + std::pair<int&, int&> blah(x, y); + return blah; +} + +std::tuple<int&, int&> +foo2() +{ + const std::pair<int&, int&> blah(x, y); + return blah; +} + +std::tuple<int&, int&> +foo3() +{ + std::pair<int&, int&> blah(x, y); + return std::tuple<int&, int&>(std::move(blah)); +} + +std::tuple<int&, int&> +foo4() +{ + const std::pair<int&, int&> blah(x, y); + return std::tuple<int&, int&>(std::move(blah)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc new file mode 100644 index 000000000..87e59098d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <tuple> + +typedef std::tuple<int> Tuple_1; +typedef std::tuple<int, int> Tuple_2; +typedef std::tuple<int, int, int> 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/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc new file mode 100644 index 000000000..bdec0c04e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <tuple> + +void f() +{ + int i = 0; + std::tuple<int&, int> t __attribute__((unused)) = std::forward_as_tuple(i, 0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc new file mode 100644 index 000000000..9b1c6a7f3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc @@ -0,0 +1,169 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +// 20.4.2.1 [tuple.cnstr] Allocator-extended constructors + +#include <memory> +#include <tuple> +#include <testsuite_hooks.h> + +struct MyAlloc { }; + +// type that can't be constructed with an allocator +struct CannotUse +{ + CannotUse(int = 0, int = 0) : ok(true) { } + + bool ok; +}; + +// type that can be constructed with an allocator +// but which has uses_allocator == false +struct DoesNotUse +{ + typedef MyAlloc allocator_type; + + DoesNotUse(int = 0) : ok(true) { } + DoesNotUse(std::allocator_arg_t, MyAlloc, int = 0) : ok(false) { } + DoesNotUse(MyAlloc) : ok(false) { } + DoesNotUse(int, MyAlloc) : ok(false) { } + + DoesNotUse(const DoesNotUse&) : ok(true) { } + DoesNotUse(std::allocator_arg_t, MyAlloc, const DoesNotUse&) : ok(false) { } + DoesNotUse(const DoesNotUse&, MyAlloc) : ok(false) { } + + DoesNotUse(DoesNotUse&&) : ok(true) { } + DoesNotUse(std::allocator_arg_t, MyAlloc, DoesNotUse&&) : ok(false) { } + DoesNotUse(DoesNotUse&&, MyAlloc) : ok(false) { } + + bool ok; +}; + +namespace std +{ + template<typename A> + struct uses_allocator<DoesNotUse, A> : false_type { }; +} + +// type that can be constructed with an allocator as second argument +struct UsesWithTag +{ + typedef MyAlloc allocator_type; + + UsesWithTag(int = 0) : ok(false) { } + UsesWithTag(std::allocator_arg_t, MyAlloc, int = 0) : ok(true) { } + UsesWithTag(MyAlloc) : ok(false) { } + UsesWithTag(int, MyAlloc) : ok(false) { } + + UsesWithTag(const UsesWithTag&) : ok(false) { } + UsesWithTag(std::allocator_arg_t, MyAlloc, const UsesWithTag&) : ok(true) { } + UsesWithTag(const UsesWithTag&, MyAlloc) : ok(false) { } + + UsesWithTag(UsesWithTag&&) : ok(false) { } + UsesWithTag(std::allocator_arg_t, MyAlloc, UsesWithTag&&) : ok(true) { } + UsesWithTag(UsesWithTag&&, MyAlloc) : ok(false) { } + + bool ok; +}; + +// type that can be constructed with an allocator as last argument +struct UsesWithoutTag +{ + typedef MyAlloc allocator_type; + + UsesWithoutTag(int = 0) : ok(false) { } + UsesWithoutTag(MyAlloc) : ok(true) { } + UsesWithoutTag(int, MyAlloc) : ok(true) { } + + UsesWithoutTag(const UsesWithoutTag&) : ok(false) { } + UsesWithoutTag(const UsesWithoutTag&, MyAlloc) : ok(true) { } + + UsesWithoutTag(UsesWithoutTag&&) : ok(false) { } + UsesWithoutTag(UsesWithoutTag&&, MyAlloc) : ok(true) { } + + bool ok; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::allocator_arg; + using std::tuple; + using std::make_tuple; + using std::get; + + typedef CannotUse T1; + typedef DoesNotUse T2; + typedef UsesWithTag T3; + typedef UsesWithoutTag T4; + typedef tuple<T1, T2, T3, T4> test_type; + + MyAlloc a; + + // default construction + test_type t1(allocator_arg, a); + VERIFY( get<0>(t1).ok ); + VERIFY( get<1>(t1).ok ); + VERIFY( get<2>(t1).ok ); + VERIFY( get<3>(t1).ok ); + + // copy construction + test_type t2(allocator_arg, a, t1); + VERIFY( get<0>(t2).ok ); + VERIFY( get<1>(t2).ok ); + VERIFY( get<2>(t2).ok ); + VERIFY( get<3>(t2).ok ); + + // move construction + test_type t3(allocator_arg, a, std::move(t1)); + VERIFY( get<0>(t3).ok ); + VERIFY( get<1>(t3).ok ); + VERIFY( get<2>(t3).ok ); + VERIFY( get<3>(t3).ok ); + + // construction from int + test_type t4(allocator_arg, a, 1, 2, 3, 4); + VERIFY( get<0>(t4).ok ); + VERIFY( get<1>(t4).ok ); + VERIFY( get<2>(t4).ok ); + VERIFY( get<3>(t4).ok ); + + auto ints = make_tuple(1, 2, 3, 4); + + // construction from lvalue tuple of ints + test_type t5(allocator_arg, a, ints); + VERIFY( get<0>(t5).ok ); + VERIFY( get<1>(t5).ok ); + VERIFY( get<2>(t5).ok ); + VERIFY( get<3>(t2).ok ); + + // construction from rvalue tuple of ints + test_type t6(allocator_arg, a, std::move(ints)); + VERIFY( get<0>(t6).ok ); + VERIFY( get<1>(t6).ok ); + VERIFY( get<2>(t6).ok ); + VERIFY( get<3>(t6).ok ); + +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc new file mode 100644 index 000000000..62c27075d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// Tuple + +#include <tuple> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + tuple<> ta; + tuple<> tb; + ta = tb; + + tuple<int> tc(1); + tuple<int> td(0); + td = tc; + VERIFY(get<0>(td) == 1); + + int i=0; + tuple<int&> te(i); + te = tc; + VERIFY(i == 1); + + tuple<const int&> tf(tc); + + get<0>(tc) = 2; + VERIFY(get<0>(tf) == 2); + tuple<double> tg; + tg = tc; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc new file mode 100644 index 000000000..40db4a43c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc @@ -0,0 +1,105 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// Tuple + +#include <tuple> +#include <utility> // for pair +#include <testsuite_hooks.h> + +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<int,int> tb; + // Test construction from values + tuple<int,int> tc(x1,x2); + tuple<int,int&> td(x1,x2); + tuple<const int&> 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<int,int> tf(tc); + tuple<int,int> tg(td); + tuple<const int&> th(te); + // Test different tuple copy constructor + tuple<int,double> ti(tc); + tuple<int,double> tj(td); + // Test constructing from a pair + pair<int,int> pair1(1,1); + const pair<int,int> pair2(pair1); + tuple<int,int> tl(pair1); + tuple<int,const int&> tm(pair1); + tuple<int,int> tn(pair2); + tuple<int,const int&> to(pair2); +} + +int +main(void) +{ + //test construction + typedef tuple<int,int,int,int,int,int,int,int,int,int> 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<int,int,int,int,int,int,int,int,int,char> type2; + type2 d(0, 0, 0, 0, 0, 0, 0, 0, 0, 3); + type1 e(d); + typedef tuple<foo,int,int,int,int,int,int,int,int,foo> type3; + // get + VERIFY(get<9>(a)==1 && get<9>(b)==2); + // comparisons + VERIFY(a==a && !(a!=a) && a<=a && a>=a && !(a<a) && !(a>a)); + VERIFY(!(a==b) && 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<type3>::value == 10); + //tuple_element + { + foo q1; + tuple_element<0,type3>::type q2(q1); + tuple_element<9,type3>::type q3(q1); + } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-2.cc new file mode 100644 index 000000000..8f2e68351 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-2.cc @@ -0,0 +1,63 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <memory> +#include <testsuite_common_types.h> + +#include <iostream> + +// 2 element tuple +int main() +{ + typedef std::tuple<int, int> tuple_type; + + // 01: default ctor + __gnu_test::constexpr_default_constructible test1; + test1.operator()<tuple_type>(); + + // 02: default copy ctor + __gnu_test::constexpr_single_value_constructible test2; + test2.operator()<tuple_type, tuple_type>(); + + // 03: element move ctor, single element + const int i1(415); + constexpr tuple_type t2 { 44, std::move(i1) }; + + // 04: element move ctor, two element + const int i2(510); + const int i3(408); + constexpr tuple_type t4 { std::move(i2), std::move(i3) }; + + // 05: value-type conversion constructor + const int i4(650); + const int i5(310); + constexpr tuple_type t8(i4, i5); + + // 06: pair conversion ctor + test2.operator()<tuple_type, std::pair<int, int>>(); + test2.operator()<std::tuple<short, short>, std::pair<int, int>>(); + test2.operator()<tuple_type, std::pair<short, short>>(); + + // 07: different-tuple-type conversion constructor + test2.operator()<tuple_type, std::tuple<short, short>>(); + test2.operator()<std::tuple<short, short>, tuple_type>(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-3.cc new file mode 100644 index 000000000..5af48128d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-3.cc @@ -0,0 +1,60 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <memory> +#include <testsuite_common_types.h> + +#include <iostream> + +// 3 element tuple +int main() +{ + typedef std::tuple<int, int, int> tuple_type; + + // 01: default ctor + __gnu_test::constexpr_default_constructible test1; + test1.operator()<tuple_type>(); + + // 02: default copy ctor + __gnu_test::constexpr_single_value_constructible test2; + test2.operator()<tuple_type, tuple_type>(); + + // 03: element move ctor, single element + const int i1(415); + constexpr tuple_type t2 { 44, 55, std::move(i1) }; + + // 04: element move ctor, three element + const int i2(510); + const int i3(408); + const int i4(650); + constexpr tuple_type t4 { std::move(i2), std::move(i3), std::move(i4) }; + + // 05: value-type conversion constructor + const int i5(310); + const int i6(310); + const int i7(310); + constexpr tuple_type t8(i5, i6, i7); + + // 06: different-tuple-type conversion constructor + test2.operator()<tuple_type, std::tuple<short, short, short>>(); + test2.operator()<std::tuple<short, short, short>, tuple_type>(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc new file mode 100644 index 000000000..8542423d2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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 +// <http://www.gnu.org/licenses/>. + +// Tuple + +#include <tuple> +#include <utility> // for pair +#include <testsuite_hooks.h> + +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<int,int> tb; + // Test construction from values + tuple<int,int> tc(x1,x2); + tuple<int,int&> td(x1,x2); + tuple<const int&> 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<int,int> tf(tc); + tuple<int,int> tg(td); + tuple<const int&> th(te); + // Test different tuple copy constructor + tuple<int,double> ti(tc); + tuple<int,double> tj(td); + //tuple<int&, int&> tk(tc); + tuple<const int&, const int&> tl(tc); + tuple<const int&, const int&> tm(tl); + // Test constructing from a pair + pair<int,int> pair1(1,1); + const pair<int,int> pair2(pair1); + tuple<int,int> tn(pair1); + tuple<int,const int&> to(pair1); + tuple<int,int> tp(pair2); + tuple<int,const int&> tq(pair2); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc new file mode 100644 index 000000000..e298a8167 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <tuple> + +// http://gcc.gnu.org/ml/libstdc++/2008-02/msg00047.html +std::tuple<int> ts1; +std::tuple<unsigned> tu1(ts1); + +std::tuple<int, int> ts2; +std::tuple<unsigned, unsigned> tu2(ts2); + +std::tuple<int, int, int> ts3; +std::tuple<unsigned, unsigned, unsigned> tu3(ts3); + +std::tuple<int, unsigned> tm2; +std::tuple<unsigned, int> tm2_(tm2); + +std::tuple<int, unsigned, int> tm3; +std::tuple<unsigned, int, unsigned> tm3_(tm3); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..ad92ea7cd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_move_construct.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 +// <http://www.gnu.org/licenses/>. + +#include <tuple> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +typedef std::tuple<int> tt1; +typedef std::tuple<int, double> tt2; +typedef std::tuple<short, double, int> tt3; +typedef std::tuple<short, NoexceptMoveConsClass, double> tt4; +typedef std::tuple<NoexceptMoveConsClass, + NoexceptMoveConsClass, double> tt5; +typedef std::tuple<NoexceptMoveConsClass, + NoexceptMoveConsClass, + NoexceptMoveConsClass> tt6; +typedef std::tuple<ExceptMoveConsClass> tt7; +typedef std::tuple<ExceptMoveConsClass, double> tt8; +typedef std::tuple<short, double, ExceptMoveConsClass> tt9; +typedef std::tuple<ExceptMoveConsClass, double, + ExceptMoveConsClass> tt10; +typedef std::tuple<NoexceptMoveConsClass, + ExceptMoveConsClass> tt11; +typedef std::tuple<int, + NoexceptMoveConsClass, + ExceptMoveConsClass> tt12; + +static_assert(std::is_nothrow_move_constructible<tt1>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt2>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt3>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt4>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt5>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt6>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt7>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt8>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt9>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt10>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt11>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt12>::value, "Error"); |