Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 +0000 | [diff] [blame] | 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> |
Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 +0000 | [diff] [blame] | 21 | |
| 22 | template <class CharT> |
| 23 | void |
| 24 | test(const std::basic_string<CharT>& s) |
| 25 | { |
| 26 | typedef std::basic_string<CharT> string; |
| 27 | typedef std::sub_match<typename string::const_iterator> SM; |
| 28 | typedef std::basic_ostringstream<CharT> ostringstream; |
| 29 | SM sm; |
| 30 | sm.first = s.begin(); |
| 31 | sm.second = s.end(); |
| 32 | sm.matched = true; |
| 33 | ostringstream os; |
| 34 | os << sm; |
| 35 | assert(os.str() == s); |
| 36 | } |
| 37 | |
| 38 | int main() |
| 39 | { |
| 40 | test(std::string("123")); |
| 41 | test(std::wstring(L"123")); |
| 42 | } |