1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. 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 23 int main() 24 { 25 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 26 { 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)-1, 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 } 63 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 64 } 65