40 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <regex>10// UNSUPPORTED: no-exceptions11 12// template <class OutputIterator, class BidirectionalIterator,13// class traits, class charT, class ST, class SA>14// OutputIterator15// regex_replace(OutputIterator out,16// BidirectionalIterator first, BidirectionalIterator last,17// const basic_regex<charT, traits>& e,18// const basic_string<charT, ST, SA>& fmt,19// regex_constants::match_flag_type flags =20// regex_constants::match_default);21 22#include <regex>23#include <cassert>24 25#include "test_macros.h"26 27int main(int, char**)28{29 try {30 std::regex re("a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaa");31 const char s[] = "aaaaaaaaaaaaaaaaaaaa";32 std::string r = std::regex_replace(s, re, "123-&", std::regex_constants::format_sed);33 LIBCPP_ASSERT(false);34 assert(r == "123-aaaaaaaaaaaaaaaaaaaa");35 } catch (const std::regex_error &e) {36 assert(e.code() == std::regex_constants::error_complexity);37 }38 return 0;39}40