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 | // operator string_type() const; |
| 15 | |
| 16 | #include <regex> |
| 17 | #include <cassert> |
| 18 | |
| 19 | int main() |
| 20 | { |
| 21 | { |
| 22 | typedef char CharT; |
| 23 | typedef std::sub_match<const CharT*> SM; |
| 24 | SM sm = SM(); |
| 25 | SM::string_type str = sm; |
| 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; |
| 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; |
| 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; |
| 45 | assert(str == std::wstring(L"123")); |
| 46 | } |
| 47 | } |