• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <regex>
11 
12 // template <class BidirectionalIterator> class sub_match;
13 
14 // string_type str() const;
15 
16 #include <regex>
17 #include <cassert>
18 #include "test_macros.h"
19 
main()20 int main()
21 {
22     {
23         typedef char CharT;
24         typedef std::sub_match<const CharT*> SM;
25         SM sm = SM();
26         SM::string_type str = sm.str();
27         assert(str.empty());
28         const CharT s[] = {'1', '2', '3', 0};
29         sm.first = s;
30         sm.second = s + 3;
31         sm.matched = true;
32         str = sm.str();
33         assert(str == std::string("123"));
34     }
35     {
36         typedef wchar_t CharT;
37         typedef std::sub_match<const CharT*> SM;
38         SM sm = SM();
39         SM::string_type str = sm.str();
40         assert(str.empty());
41         const CharT s[] = {'1', '2', '3', 0};
42         sm.first = s;
43         sm.second = s + 3;
44         sm.matched = true;
45         str = sm.str();
46         assert(str == std::wstring(L"123"));
47     }
48 }
49