1cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant//===----------------------------------------------------------------------===//
2cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant//
3cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant//                     The LLVM Compiler Infrastructure
4cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant//
5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details.
7cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant//
8cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant//===----------------------------------------------------------------------===//
9cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant
10cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant// <regex>
11cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant
12cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant// template <class BidirectionalIterator> class sub_match;
13cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant
14cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant// template <class charT, class ST, class BiIter>
15cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant//     basic_ostream<charT, ST>&
16cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant//     operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
17cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant
18cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant#include <regex>
19cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant#include <sstream>
20cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant#include <cassert>
21cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant
22cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnanttemplate <class CharT>
23cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnantvoid
24cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnanttest(const std::basic_string<CharT>& s)
25cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant{
26cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    typedef std::basic_string<CharT> string;
27cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    typedef std::sub_match<typename string::const_iterator> SM;
28cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    typedef std::basic_ostringstream<CharT> ostringstream;
29cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    SM sm;
30cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    sm.first = s.begin();
31cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    sm.second = s.end();
32cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    sm.matched = true;
33cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    ostringstream os;
34cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    os << sm;
35cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    assert(os.str() == s);
36cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant}
37cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant
38cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnantint main()
39cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant{
40cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    test(std::string("123"));
41cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant    test(std::wstring(L"123"));
42cd85b9ee137e179cf38d935fc500e12521ccd3d2Howard Hinnant}
43