15a83710eSEric Fiselier //===----------------------------------------------------------------------===// 25a83710eSEric Fiselier // 357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 65a83710eSEric Fiselier // 75a83710eSEric Fiselier //===----------------------------------------------------------------------===// 85a83710eSEric Fiselier 95a83710eSEric Fiselier // <regex> 105a83710eSEric Fiselier 115a83710eSEric Fiselier // template <class charT, class traits = regex_traits<charT>> class basic_regex; 125a83710eSEric Fiselier 135a83710eSEric Fiselier // basic_regex& assign(const basic_regex& that); 145a83710eSEric Fiselier 155a83710eSEric Fiselier #include <regex> 165a83710eSEric Fiselier #include <cassert> 17fd5ceb22SMarshall Clow #include "test_macros.h" 185a83710eSEric Fiselier main(int,char **)19*2df59c50SJF Bastienint main(int, char**) 205a83710eSEric Fiselier { 215a83710eSEric Fiselier std::regex r1("(a([bc]))"); 225a83710eSEric Fiselier std::regex r2; 235a83710eSEric Fiselier r2.assign(r1); 245a83710eSEric Fiselier assert(r2.flags() == std::regex::ECMAScript); 255a83710eSEric Fiselier assert(r2.mark_count() == 2); 269db9069cSMarshall Clow assert(std::regex_search("ab", r2)); 279db9069cSMarshall Clow 2808eb2148SAsiri Rathnayake #ifndef TEST_HAS_NO_EXCEPTIONS 299db9069cSMarshall Clow bool caught = false; 309db9069cSMarshall Clow try { r2.assign("(def", std::regex::extended); } 319db9069cSMarshall Clow catch(std::regex_error &) { caught = true; } 329db9069cSMarshall Clow assert(caught); 339db9069cSMarshall Clow assert(r2.flags() == std::regex::ECMAScript); 349db9069cSMarshall Clow assert(r2.mark_count() == 2); 359db9069cSMarshall Clow assert(std::regex_search("ab", r2)); 3608eb2148SAsiri Rathnayake #endif 37*2df59c50SJF Bastien 38*2df59c50SJF Bastien return 0; 395a83710eSEric Fiselier } 40