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// basic_regex(const charT* p, size_t len);
14
15#include <regex>
16#include <cassert>
17
18#include "test_macros.h"
19
20template <class CharT>
21void
22test(const CharT* p, std::size_t len, unsigned mc)
23{
24 std::basic_regex<CharT> r(p, len);
25 assert(r.flags() == std::regex_constants::ECMAScript);
26 assert(r.mark_count() == mc);
27}
28
29int main(int, char**)
30{
31 test(p: "\\(a\\)", len: 5, mc: 0);
32 test("\\(a[bc]\\)", 9, 0);
33 test("\\(a\\([bc]\\)\\)", 13, 0);
34 test("(a([bc]))", 9, 2);
35
36 test("(\0)(b)(c)(d)", 12, 4);
37 test("(\0)(b)(c)(d)", 9, 3);
38 test("(\0)(b)(c)(d)", 3, 1);
39 test("(\0)(b)(c)(d)", 0, 0);
40
41 return 0;
42}
43

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