header_regex_synop.pass.cpp (1941B)
1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is dual licensed under the MIT and the University of Illinois Open 7 // Source Licenses. See LICENSE.TXT for details. 8 // 9 //===----------------------------------------------------------------------===// 10 11 // REQUIRES: c++experimental 12 // UNSUPPORTED: c++98, c++03 13 14 // <experimental/regex> 15 16 // namespace std { namespace experimental { namespace 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::experimental::pmr 29 30 #include <experimental/regex> 31 #include <type_traits> 32 #include <cassert> 33 34 namespace pmr = std::experimental::pmr; 35 36 template <class Iter, class PmrTypedef> 37 void test_match_result_typedef() { 38 using StdMR = std::match_results<Iter, pmr::polymorphic_allocator<std::sub_match<Iter>>>; 39 using PmrMR = pmr::match_results<Iter>; 40 static_assert(std::is_same<StdMR, PmrMR>::value, ""); 41 static_assert(std::is_same<PmrMR, PmrTypedef>::value, ""); 42 } 43 44 int main() 45 { 46 { 47 test_match_result_typedef<const char*, pmr::cmatch>(); 48 test_match_result_typedef<const wchar_t*, pmr::wcmatch>(); 49 test_match_result_typedef<pmr::string::const_iterator, pmr::smatch>(); 50 test_match_result_typedef<pmr::wstring::const_iterator, pmr::wsmatch>(); 51 } 52 { 53 // Check that std::match_results has been included and is complete. 54 pmr::smatch s; 55 assert(s.get_allocator().resource() == pmr::get_default_resource()); 56 } 57 }