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 // XFAIL: libcpp-no-exceptions 11 // <regex> 12 13 // template <class charT, class traits = regex_traits<charT>> class basic_regex; 14 15 // basic_regex& assign(const basic_regex& that); 16 17 #include <regex> 18 #include <cassert> 19 20 int main() 21 { 22 std::regex r1("(a([bc]))"); 23 std::regex r2; 24 r2.assign(r1); 25 assert(r2.flags() == std::regex::ECMAScript); 26 assert(r2.mark_count() == 2); 27 assert(std::regex_search("ab", r2)); 28 29 bool caught = false; 30 try { r2.assign("(def", std::regex::extended); } 31 catch(std::regex_error &) { caught = true; } 32 assert(caught); 33 assert(r2.flags() == std::regex::ECMAScript); 34 assert(r2.mark_count() == 2); 35 assert(std::regex_search("ab", r2)); 36 } 37