]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/28_regex/basic_regex/ctors/deduction.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 28_regex / basic_regex / ctors / deduction.cc
CommitLineData
7adcbafe 1// Copyright (C) 2017-2022 Free Software Foundation, Inc.
bfd88d1d
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 } }
218cedd5 19// { dg-timeout-factor 3 }
bfd88d1d
JW
20
21#include <regex>
22#include <testsuite_iterators.h>
23
24template<typename T, typename U> struct require_same;
25template<typename T> struct require_same<T, T> { using type = void; };
26
27template<typename T, typename U>
28 typename require_same<T, U>::type
29 check_type(U&) { }
30
31void
32test01()
33{
34 std::basic_regex x("");
35 check_type<std::basic_regex<char>>(x);
36 char s[1] = {};
37 std::basic_regex x2(s);
38 check_type<std::basic_regex<char>>(x2);
39 std::basic_regex x3(U"");
40 check_type<std::basic_regex<char32_t>>(x3);
41 std::basic_regex x4(U"", std::regex_constants::grep);
42 check_type<std::basic_regex<char32_t>>(x4);
43
44 // Test explicit guide:
45 std::basic_regex x5(s, s+1);
46 check_type<std::basic_regex<char>>(x5);
47 std::basic_regex x6((const char*)s, (const char*)s+1);
48 check_type<std::basic_regex<char>>(x6);
49 std::basic_regex x7(s, s+1, std::regex_constants::grep);
50 check_type<std::basic_regex<char>>(x7);
51 __gnu_test::test_container<char, __gnu_test::forward_iterator_wrapper> f(s);
52 std::basic_regex x8(f.begin(), f.end());
53 check_type<std::basic_regex<char>>(x8);
54 std::basic_regex x9(f.begin(), f.end(), std::regex_constants::grep);
55 check_type<std::basic_regex<char>>(x9);
56
57 std::basic_regex copy = x;
58 check_type<std::basic_regex<char>>(copy);
59 std::basic_regex move = std::move(x);
60 check_type<std::basic_regex<char>>(move);
61}