blob: 45969b4df22212cdc0030c66f42ee7b1fc04a970 [file] [log] [blame]
Howard Hinnant262b7792010-08-17 20:42:03 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <regex>
11
12// class regex_token_iterator<BidirectionalIterator, charT, traits>
13
14// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
15// const regex_type& re,
16// initializer_list<int> submatches,
17// regex_constants::match_flag_type m =
18// regex_constants::match_default);
19
20#include <regex>
21#include <cassert>
22
23int main()
24{
Howard Hinnant73d21a42010-09-04 23:28:19 +000025#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant262b7792010-08-17 20:42:03 +000026 {
27 std::regex phone_numbers("\\d{3}-(\\d{4})");
28 const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
29 std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book),
30 phone_numbers, {-1, 0, 1});
31 assert(i != std::cregex_token_iterator());
32 assert(i->str() == "start ");
33 ++i;
34 assert(i != std::cregex_token_iterator());
35 assert(i->str() == "555-1234");
36 ++i;
37 assert(i != std::cregex_token_iterator());
38 assert(i->str() == "1234");
39 ++i;
40 assert(i != std::cregex_token_iterator());
41 assert(i->str() == ", ");
42 ++i;
43 assert(i != std::cregex_token_iterator());
44 assert(i->str() == "555-2345");
45 ++i;
46 assert(i != std::cregex_token_iterator());
47 assert(i->str() == "2345");
48 ++i;
49 assert(i != std::cregex_token_iterator());
50 assert(i->str() == ", ");
51 ++i;
52 assert(i != std::cregex_token_iterator());
53 assert(i->str() == "555-3456");
54 ++i;
55 assert(i != std::cregex_token_iterator());
56 assert(i->str() == "3456");
57 ++i;
58 assert(i != std::cregex_token_iterator());
59 assert(i->str() == " end");
60 ++i;
61 assert(i == std::cregex_token_iterator());
62 }
Howard Hinnant73d21a42010-09-04 23:28:19 +000063#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnanta8d77592010-08-18 00:13:08 +000064}