1dd426c2fSMarshall Clow //===----------------------------------------------------------------------===//
2dd426c2fSMarshall Clow //
3dd426c2fSMarshall Clow // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4dd426c2fSMarshall Clow // See https://llvm.org/LICENSE.txt for license information.
5dd426c2fSMarshall Clow // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6dd426c2fSMarshall Clow //
7dd426c2fSMarshall Clow //===----------------------------------------------------------------------===//
8dd426c2fSMarshall Clow
9dd426c2fSMarshall Clow // <regex>
10*8c61114cSLouis Dionne // UNSUPPORTED: no-exceptions
11dd426c2fSMarshall Clow
12dd426c2fSMarshall Clow // template <class OutputIterator, class BidirectionalIterator,
13dd426c2fSMarshall Clow // class traits, class charT, class ST, class SA>
14dd426c2fSMarshall Clow // OutputIterator
15dd426c2fSMarshall Clow // regex_replace(OutputIterator out,
16dd426c2fSMarshall Clow // BidirectionalIterator first, BidirectionalIterator last,
17dd426c2fSMarshall Clow // const basic_regex<charT, traits>& e,
18dd426c2fSMarshall Clow // const basic_string<charT, ST, SA>& fmt,
19dd426c2fSMarshall Clow // regex_constants::match_flag_type flags =
20dd426c2fSMarshall Clow // regex_constants::match_default);
21dd426c2fSMarshall Clow
22dd426c2fSMarshall Clow #include <regex>
23dd426c2fSMarshall Clow #include <cassert>
24dd426c2fSMarshall Clow
25dd426c2fSMarshall Clow #include "test_macros.h"
26dd426c2fSMarshall Clow
main(int,char **)272df59c50SJF Bastien int main(int, char**)
28dd426c2fSMarshall Clow {
29dd426c2fSMarshall Clow try {
30dd426c2fSMarshall Clow std::regex re("a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaa");
31dd426c2fSMarshall Clow const char s[] = "aaaaaaaaaaaaaaaaaaaa";
32dd426c2fSMarshall Clow std::string r = std::regex_replace(s, re, "123-&", std::regex_constants::format_sed);
33dd426c2fSMarshall Clow LIBCPP_ASSERT(false);
34dd426c2fSMarshall Clow assert(r == "123-aaaaaaaaaaaaaaaaaaaa");
35dd426c2fSMarshall Clow } catch (const std::regex_error &e) {
36dd426c2fSMarshall Clow assert(e.code() == std::regex_constants::error_complexity);
37dd426c2fSMarshall Clow }
382df59c50SJF Bastien return 0;
39dd426c2fSMarshall Clow }
40