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
10 // UNSUPPORTED: no-localization
11
12 // Aligned allocation is required by std::experimental::pmr, but it was not provided
13 // before macosx10.13 and as a result we get linker errors when deploying to older than
14 // macosx10.13.
15 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}
16
17 // <experimental/regex>
18
19 // namespace std { namespace experimental { namespace pmr {
20 //
21 // template <class BidirectionalIterator>
22 // using match_results =
23 // std::match_results<BidirectionalIterator,
24 // polymorphic_allocator<sub_match<BidirectionalIterator>>>;
25 //
26 // typedef match_results<const char*> cmatch;
27 // typedef match_results<const wchar_t*> wcmatch;
28 // typedef match_results<string::const_iterator> smatch;
29 // typedef match_results<wstring::const_iterator> wsmatch;
30 //
31 // }}} // namespace std::experimental::pmr
32
33 #include <experimental/regex>
34 #include <type_traits>
35 #include <cassert>
36
37 #include "test_macros.h"
38
39 namespace pmr = std::experimental::pmr;
40
41 template <class Iter, class PmrTypedef>
test_match_result_typedef()42 void test_match_result_typedef() {
43 using StdMR = std::match_results<Iter, pmr::polymorphic_allocator<std::sub_match<Iter>>>;
44 using PmrMR = pmr::match_results<Iter>;
45 static_assert(std::is_same<StdMR, PmrMR>::value, "");
46 static_assert(std::is_same<PmrMR, PmrTypedef>::value, "");
47 }
48
main(int,char **)49 int main(int, char**)
50 {
51 {
52 test_match_result_typedef<const char*, pmr::cmatch>();
53 test_match_result_typedef<pmr::string::const_iterator, pmr::smatch>();
54 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
55 test_match_result_typedef<const wchar_t*, pmr::wcmatch>();
56 test_match_result_typedef<pmr::wstring::const_iterator, pmr::wsmatch>();
57 #endif
58 }
59 {
60 // Check that std::match_results has been included and is complete.
61 pmr::smatch s;
62 assert(s.get_allocator().resource() == pmr::get_default_resource());
63 }
64
65 return 0;
66 }
67