Skip to content

Commit 614c406

Browse files
committedAug 7, 2016
[libcxx] Add "flag" default arg: basic_regex ptr_size_flag ctor
Summary: The synopsis in C++11 subclause 28.8 [re.regex] has: ``` basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript); ``` The default argument is added to libc++ by this change. Reviewers: mclow.lists, rsmith, hubert.reinterpretcast Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D22702 llvm-svn: 277966
1 parent f444231 commit 614c406

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed
 

‎libcxx/include/regex

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public:
147147
// construct/copy/destroy:
148148
basic_regex();
149149
explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
150-
basic_regex(const charT* p, size_t len, flag_type f);
150+
basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
151151
basic_regex(const basic_regex&);
152152
basic_regex(basic_regex&&) noexcept;
153153
template <class ST, class SA>
@@ -2519,7 +2519,7 @@ public:
25192519
__end_(0)
25202520
{__parse(__p, __p + __traits_.length(__p));}
25212521
_LIBCPP_INLINE_VISIBILITY
2522-
basic_regex(const value_type* __p, size_t __len, flag_type __f)
2522+
basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
25232523
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
25242524
__end_(0)
25252525
{__parse(__p, __p + __len);}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
// template <class charT, class traits = regex_traits<charT>> class basic_regex;
13+
14+
// basic_regex(const charT* p, size_t len);
15+
16+
#include <regex>
17+
#include <cassert>
18+
19+
template <class CharT>
20+
void
21+
test(const CharT* p, std::size_t len, unsigned mc)
22+
{
23+
std::basic_regex<CharT> r(p, len);
24+
assert(r.flags() == std::regex_constants::ECMAScript);
25+
assert(r.mark_count() == mc);
26+
}
27+
28+
int main()
29+
{
30+
test("\\(a\\)", 5, 0);
31+
test("\\(a[bc]\\)", 9, 0);
32+
test("\\(a\\([bc]\\)\\)", 13, 0);
33+
test("(a([bc]))", 9, 2);
34+
35+
test("(\0)(b)(c)(d)", 12, 4);
36+
test("(\0)(b)(c)(d)", 9, 3);
37+
test("(\0)(b)(c)(d)", 3, 1);
38+
test("(\0)(b)(c)(d)", 0, 0);
39+
}

0 commit comments

Comments
 (0)
Please sign in to comment.