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 // UNSUPPORTED: c++03, c++11, c++14
10 // UNSUPPORTED: no-localization
11 // TODO: Change to XFAIL once https://github.com/llvm/llvm-project/issues/40340 is fixed
12 // UNSUPPORTED: availability-pmr-missing
13
14 // <regex>
15
16 // namespace std::pmr {
17 //
18 // template <class BidirectionalIterator>
19 // using match_results =
20 // std::match_results<BidirectionalIterator,
21 // polymorphic_allocator<sub_match<BidirectionalIterator>>>;
22 //
23 // typedef match_results<const char*> cmatch;
24 // typedef match_results<const wchar_t*> wcmatch;
25 // typedef match_results<string::const_iterator> smatch;
26 // typedef match_results<wstring::const_iterator> wsmatch;
27 //
28 // } // namespace std::pmr
29
30 #include <regex>
31 #include <cassert>
32 #include <memory_resource>
33 #include <type_traits>
34
35 #include "test_macros.h"
36
37 template <class Iter, class PmrTypedef>
test_match_result_typedef()38 void test_match_result_typedef() {
39 using StdMR = std::match_results<Iter, std::pmr::polymorphic_allocator<std::sub_match<Iter>>>;
40 using PmrMR = std::pmr::match_results<Iter>;
41 static_assert(std::is_same<StdMR, PmrMR>::value, "");
42 static_assert(std::is_same<PmrMR, PmrTypedef>::value, "");
43 }
44
main(int,char **)45 int main(int, char**) {
46 {
47 test_match_result_typedef<const char*, std::pmr::cmatch>();
48 test_match_result_typedef<std::pmr::string::const_iterator, std::pmr::smatch>();
49 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
50 test_match_result_typedef<const wchar_t*, std::pmr::wcmatch>();
51 test_match_result_typedef<std::pmr::wstring::const_iterator, std::pmr::wsmatch>();
52 #endif
53 }
54 {
55 // Check that std::match_results has been included and is complete.
56 std::pmr::smatch s;
57 assert(s.get_allocator().resource() == std::pmr::get_default_resource());
58 }
59
60 return 0;
61 }
62