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_iterator<BidirectionalIterator, charT, traits> 13 14// const value_type& operator*() const; 15 16#include <regex> 17#include <cassert> 18#include "test_macros.h" 19 20int main() 21{ 22 { 23 std::regex phone_numbers("\\d{3}-\\d{4}"); 24 const char phone_book[] = "555-1234, 555-2345, 555-3456"; 25 std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers); 26 assert(i != std::cregex_iterator()); 27 assert((*i).size() == 1); 28 assert((*i).position() == 0); 29 assert((*i).str() == "555-1234"); 30 ++i; 31 assert(i != std::cregex_iterator()); 32 assert((*i).size() == 1); 33 assert((*i).position() == 10); 34 assert((*i).str() == "555-2345"); 35 ++i; 36 assert(i != std::cregex_iterator()); 37 assert((*i).size() == 1); 38 assert((*i).position() == 20); 39 assert((*i).str() == "555-3456"); 40 ++i; 41 assert(i == std::cregex_iterator()); 42 } 43} 44