]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/list/cons/deduction.cc
libstdc++: Remove redundant -std=gnu++17 option from containers tests
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / list / cons / deduction.cc
CommitLineData
99dee823 1// Copyright (C) 2017-2021 Free Software Foundation, Inc.
225ab2b0
JW
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.
8
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.
13
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/>.
17
7b936140 18// { dg-do compile { target c++17 } }
225ab2b0
JW
19
20#include <list>
21#include <testsuite_iterators.h>
22
23template<typename T>
24 using input_iterator_seq
25 = __gnu_test::test_container<T, __gnu_test::input_iterator_wrapper>;
26
27template<typename T, typename U> struct require_same;
28template<typename T> struct require_same<T, T> { using type = void; };
29
30template<typename T, typename U>
31 typename require_same<T, U>::type
32 check_type(U&) { }
33
34void
35test01()
36{
37 std::list<unsigned> s0;
38
39 std::list s1 = s0;
40 check_type<std::list<unsigned>>(s1);
41
42 std::list s2 = std::move(s0);
43 check_type<std::list<unsigned>>(s2);
44
45 const std::list s3 = s0;
46 check_type<const std::list<unsigned>>(s3);
47
48 const std::list s4 = s3;
49 check_type<const std::list<unsigned>>(s4);
50}
51
52void
53test02()
54{
55 unsigned a[1] = {};
56 input_iterator_seq<unsigned> seq(a);
57
58 std::list s1(seq.begin(), seq.end());
59 check_type<std::list<unsigned>>(s1);
60
61 std::list s2(seq.begin(), seq.end(), std::allocator<unsigned>());
62 check_type<std::list<unsigned>>(s2);
63
64 std::list s3(1U, 2L);
65 check_type<std::list<long>>(s3);
66
67 std::list s4(1U, 2L, std::allocator<long>());
68 check_type<std::list<long>>(s4);
69}