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 // <regex> 10 11 // template <class BidirectionalIterator> class sub_match; 12 13 // string_type str() const; 14 15 #include <regex> 16 #include <cassert> 17 #include "test_macros.h" 18 main(int,char **)19int main(int, char**) 20 { 21 { 22 typedef char CharT; 23 typedef std::sub_match<const CharT*> SM; 24 SM sm = SM(); 25 SM::string_type str = sm.str(); 26 assert(str.empty()); 27 const CharT s[] = {'1', '2', '3', 0}; 28 sm.first = s; 29 sm.second = s + 3; 30 sm.matched = true; 31 str = sm.str(); 32 assert(str == std::string("123")); 33 } 34 { 35 typedef wchar_t CharT; 36 typedef std::sub_match<const CharT*> SM; 37 SM sm = SM(); 38 SM::string_type str = sm.str(); 39 assert(str.empty()); 40 const CharT s[] = {'1', '2', '3', 0}; 41 sm.first = s; 42 sm.second = s + 3; 43 sm.matched = true; 44 str = sm.str(); 45 assert(str == std::wstring(L"123")); 46 } 47 48 return 0; 49 } 50