Howard Hinnant | 8784650 | 2010-08-12 21:14:20 +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 | 8784650 | 2010-08-12 21:14:20 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <regex> |
| 11 | |
| 12 | // template <class charT, class traits = regex_traits<charT>> class basic_regex; |
| 13 | |
| 14 | // template <class ForwardIterator> |
| 15 | // basic_regex(ForwardIterator first, ForwardIterator last); |
| 16 | |
| 17 | #include <regex> |
| 18 | #include <cassert> |
| 19 | |
Marshall Clow | 83e2c4d | 2013-01-05 03:21:01 +0000 | [diff] [blame] | 20 | #include "test_iterators.h" |
Howard Hinnant | 8784650 | 2010-08-12 21:14:20 +0000 | [diff] [blame] | 21 | |
| 22 | template <class Iter> |
| 23 | void |
| 24 | test(Iter first, Iter last, unsigned mc) |
| 25 | { |
| 26 | std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last); |
| 27 | assert(r.flags() == std::regex_constants::ECMAScript); |
| 28 | assert(r.mark_count() == mc); |
| 29 | } |
| 30 | |
| 31 | int main() |
| 32 | { |
| 33 | typedef forward_iterator<std::string::const_iterator> F; |
| 34 | std::string s1("\\(a\\)"); |
| 35 | std::string s2("\\(a[bc]\\)"); |
| 36 | std::string s3("\\(a\\([bc]\\)\\)"); |
| 37 | std::string s4("(a([bc]))"); |
| 38 | |
| 39 | test(F(s1.begin()), F(s1.end()), 0); |
| 40 | test(F(s2.begin()), F(s2.end()), 0); |
| 41 | test(F(s3.begin()), F(s3.end()), 0); |
| 42 | test(F(s4.begin()), F(s4.end()), 2); |
| 43 | } |