blob: ef9cec5f736e8f54aa033ac9a43f6ac9c48f11bd [file] [log] [blame]
Howard Hinnant7670f7d2013-07-09 17:29:09 +00001//===----------------------------------------------------------------------===//
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// template <class BidirectionalIterator, class Allocator, class charT, class traits>
13// bool
14// regex_search(BidirectionalIterator first, BidirectionalIterator last,
15// match_results<BidirectionalIterator, Allocator>& m,
16// const basic_regex<charT, traits>& e,
17// regex_constants::match_flag_type flags = regex_constants::match_default);
18
19#include <regex>
20#include <cassert>
21
22int main()
23{
24 // Iterating over /^a/ should yield one instance at the beginning
25 // of the text.
26
27 const char *text = "aaa\naa";
Eric Fiseliere4e883e2014-10-27 19:29:32 +000028 std::regex re("^a");
29 std::cregex_iterator it(text, text+6, re);
30 std::cregex_iterator end = std::cregex_iterator();
Howard Hinnant7670f7d2013-07-09 17:29:09 +000031
32 assert(it->str() == "a");
33 assert(it->position(0) == 0);
34 assert(it->length(0) == 1);
35
36 ++it;
37 assert(it == end);
38}