]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/28_regex/basic_regex/ctors/deduction.cc
1 // Copyright (C) 2017-2020 Free Software Foundation, Inc.
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)
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 } }
20 // { dg-timeout-factor 3 }
23 #include <testsuite_iterators.h>
25 template<typename T
, typename U
> struct require_same
;
26 template<typename T
> struct require_same
<T
, T
> { using type
= void; };
28 template<typename T
, typename U
>
29 typename require_same
<T
, U
>::type
35 std::basic_regex
x("");
36 check_type
<std::basic_regex
<char>>(x
);
38 std::basic_regex
x2(s
);
39 check_type
<std::basic_regex
<char>>(x2
);
40 std::basic_regex
x3(U
"");
41 check_type
<std::basic_regex
<char32_t
>>(x3
);
42 std::basic_regex
x4(U
"", std::regex_constants::grep
);
43 check_type
<std::basic_regex
<char32_t
>>(x4
);
45 // Test explicit guide:
46 std::basic_regex
x5(s
, s
+1);
47 check_type
<std::basic_regex
<char>>(x5
);
48 std::basic_regex
x6((const char*)s
, (const char*)s
+1);
49 check_type
<std::basic_regex
<char>>(x6
);
50 std::basic_regex
x7(s
, s
+1, std::regex_constants::grep
);
51 check_type
<std::basic_regex
<char>>(x7
);
52 __gnu_test::test_container
<char, __gnu_test::forward_iterator_wrapper
> f(s
);
53 std::basic_regex
x8(f
.begin(), f
.end());
54 check_type
<std::basic_regex
<char>>(x8
);
55 std::basic_regex
x9(f
.begin(), f
.end(), std::regex_constants::grep
);
56 check_type
<std::basic_regex
<char>>(x9
);
58 std::basic_regex copy
= x
;
59 check_type
<std::basic_regex
<char>>(copy
);
60 std::basic_regex move
= std::move(x
);
61 check_type
<std::basic_regex
<char>>(move
);