1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // <regex> |
10 | |
11 | // class match_results<BidirectionalIterator, Allocator> |
12 | |
13 | // explicit match_results(const Allocator& a = Allocator()); // before C++20 |
14 | // match_results() : match_results(Allocator()) {} // C++20 |
15 | // explicit match_results(const Allocator& a); // C++20 |
16 | |
17 | #include <regex> |
18 | #include <cassert> |
19 | #include "test_macros.h" |
20 | #if TEST_STD_VER >= 11 |
21 | #include "test_convertible.h" |
22 | |
23 | template <typename T> |
24 | void test_implicit() { |
25 | static_assert(test_convertible<T>(), "" ); |
26 | static_assert(!test_convertible<T, typename T::allocator_type>(), "" ); |
27 | } |
28 | #endif |
29 | |
30 | template <class CharT> |
31 | void |
32 | test() |
33 | { |
34 | typedef std::match_results<const CharT*> M; |
35 | typedef std::allocator<std::sub_match<const CharT*> > Alloc; |
36 | M m; |
37 | assert(m.size() == 0); |
38 | assert(!m.ready()); |
39 | assert(m.get_allocator() == Alloc()); |
40 | |
41 | #if TEST_STD_VER >= 11 |
42 | test_implicit<M>(); |
43 | #endif |
44 | } |
45 | |
46 | int main(int, char**) |
47 | { |
48 | test<char>(); |
49 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
50 | test<wchar_t>(); |
51 | #endif |
52 | |
53 | return 0; |
54 | } |
55 | |