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