• 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 // template <class charT, class ST, class BiIter>
15 //     basic_ostream<charT, ST>&
16 //     operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
17 
18 #include <regex>
19 #include <sstream>
20 #include <cassert>
21 #include "test_macros.h"
22 
23 template <class CharT>
24 void
test(const std::basic_string<CharT> & s)25 test(const std::basic_string<CharT>& s)
26 {
27     typedef std::basic_string<CharT> string;
28     typedef std::sub_match<typename string::const_iterator> SM;
29     typedef std::basic_ostringstream<CharT> ostringstream;
30     SM sm;
31     sm.first = s.begin();
32     sm.second = s.end();
33     sm.matched = true;
34     ostringstream os;
35     os << sm;
36     assert(os.str() == s);
37 }
38 
main()39 int main()
40 {
41     test(std::string("123"));
42     test(std::wstring(L"123"));
43 }
44