PR libstdc++/87809 avoid invalid expressions in exception specifications
[official-gcc.git] / libstdc++-v3 / testsuite / 23_containers / list / cons / deduction.cc
blobc4a5e63dbdef0fa118396a9d1d5a260a43ae7b39
1 // Copyright (C) 2017-2018 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-options "-std=gnu++17" }
19 // { dg-do compile { target c++17 } }
21 #include <list>
22 #include <testsuite_iterators.h>
24 template<typename T>
25 using input_iterator_seq
26 = __gnu_test::test_container<T, __gnu_test::input_iterator_wrapper>;
28 template<typename T, typename U> struct require_same;
29 template<typename T> struct require_same<T, T> { using type = void; };
31 template<typename T, typename U>
32 typename require_same<T, U>::type
33 check_type(U&) { }
35 void
36 test01()
38 std::list<unsigned> s0;
40 std::list s1 = s0;
41 check_type<std::list<unsigned>>(s1);
43 std::list s2 = std::move(s0);
44 check_type<std::list<unsigned>>(s2);
46 const std::list s3 = s0;
47 check_type<const std::list<unsigned>>(s3);
49 const std::list s4 = s3;
50 check_type<const std::list<unsigned>>(s4);
53 void
54 test02()
56 unsigned a[1] = {};
57 input_iterator_seq<unsigned> seq(a);
59 std::list s1(seq.begin(), seq.end());
60 check_type<std::list<unsigned>>(s1);
62 std::list s2(seq.begin(), seq.end(), std::allocator<unsigned>());
63 check_type<std::list<unsigned>>(s2);
65 std::list s3(1U, 2L);
66 check_type<std::list<long>>(s3);
68 std::list s4(1U, 2L, std::allocator<long>());
69 check_type<std::list<long>>(s4);