| 1 |
// Copyright (C) 2017-2025 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. |
| 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-do compile { target c++17 } } |
| 19 |
// { dg-timeout-factor 3 } |
| 20 |
|
| 21 |
#include <regex> |
| 22 |
#include <testsuite_iterators.h> |
| 23 |
|
| 24 |
template<typename T, typename U> struct require_same; |
| 25 |
template<typename T> struct require_same<T, T> { using type = void; }; |
| 26 |
|
| 27 |
template<typename T, typename U> |
| 28 |
typename require_same<T, U>::type |
| 29 |
check_type(U&) { } |
| 30 |
|
| 31 |
void |
| 32 |
test01() |
| 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 |
} |