Debian Codegraph @

libstdc++-v3/testsuite/28_regex/basic_regex/assign/exception_safety.cc

raw
1 // { dg-do run { target c++11 } }
2 #include <regex>
3 #include <testsuite_hooks.h>
4
5 int main()
6 {
7 const auto f = std::regex::ECMAScript|std::regex::icase;
8 std::regex re("abc", f);
9 try
10 {
11 re.assign("[", std::regex::extended);
12 VERIFY( false );
13 }
14 catch (const std::regex_error&)
15 {
16 // [re.regex.assign] "If an exception is thrown, *this is unchanged."
17 VERIFY( re.flags() == f );
18 VERIFY( std::regex_match("abc", re) );
19 }
20 }