1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <regex>
10
11// template <class charT, class traits = regex_traits<charT>> class basic_regex;
12
13// template <class ForwardIterator>
14// basic_regex(ForwardIterator first, ForwardIterator last);
15
16#include <regex>
17#include <cassert>
18
19#include "test_iterators.h"
20#include "test_macros.h"
21
22template <class Iter>
23void
24test(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
31int main(int, char**)
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(first: F(s1.begin()), last: F(s1.end()), mc: 0);
40 test(first: F(s2.begin()), last: F(s2.end()), mc: 0);
41 test(first: F(s3.begin()), last: F(s3.end()), mc: 0);
42 test(first: F(s4.begin()), last: F(s4.end()), mc: 2);
43
44 return 0;
45}
46

source code of libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp