1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++03
11 // UNSUPPORTED: libcpp-has-no-localization
12 
13 // <experimental/regex>
14 
15 // namespace std { namespace experimental { namespace pmr {
16 //
17 //  template <class BidirectionalIterator>
18 //  using match_results =
19 //    std::match_results<BidirectionalIterator,
20 //                       polymorphic_allocator<sub_match<BidirectionalIterator>>>;
21 //
22 //  typedef match_results<const char*> cmatch;
23 //  typedef match_results<const wchar_t*> wcmatch;
24 //  typedef match_results<string::const_iterator> smatch;
25 //  typedef match_results<wstring::const_iterator> wsmatch;
26 //
27 // }}} // namespace std::experimental::pmr
28 
29 #include <experimental/regex>
30 #include <type_traits>
31 #include <cassert>
32 
33 #include "test_macros.h"
34 
35 namespace pmr = std::experimental::pmr;
36 
37 template <class Iter, class PmrTypedef>
test_match_result_typedef()38 void test_match_result_typedef() {
39     using StdMR = std::match_results<Iter, pmr::polymorphic_allocator<std::sub_match<Iter>>>;
40     using PmrMR = 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     {
48         test_match_result_typedef<const char*, pmr::cmatch>();
49         test_match_result_typedef<const wchar_t*, pmr::wcmatch>();
50         test_match_result_typedef<pmr::string::const_iterator, pmr::smatch>();
51         test_match_result_typedef<pmr::wstring::const_iterator, pmr::wsmatch>();
52     }
53     {
54         // Check that std::match_results has been included and is complete.
55         pmr::smatch s;
56         assert(s.get_allocator().resource() == pmr::get_default_resource());
57     }
58 
59   return 0;
60 }
61