62 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410// UNSUPPORTED: no-localization11// TODO: Change to XFAIL once https://llvm.org/PR40995 is fixed12// UNSUPPORTED: availability-pmr-missing13 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::pmr29 30#include <regex>31#include <cassert>32#include <memory_resource>33#include <type_traits>34 35#include "test_macros.h"36 37template <class Iter, class PmrTypedef>38void 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 45int 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_CHARACTERS50 test_match_result_typedef<const wchar_t*, std::pmr::wcmatch>();51 test_match_result_typedef<std::pmr::wstring::const_iterator, std::pmr::wsmatch>();52#endif53 }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