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 // <regex> 11 12 // template <class charT, class traits = regex_traits<charT>> class basic_regex; 13 14 // template <class ST, class SA> 15 // basic_regex(const basic_string<charT, ST, SA>& s); 16 17 #include <regex> 18 #include <cassert> 19 main()20int main() 21 { 22 // Correct: Exception thrown for invalid escape char in a character class 23 try { 24 std::regex char_class_escape("[\\a]"); 25 assert(false); 26 } catch (std::regex_error &ex) { 27 assert(ex.code() == std::regex_constants::error_escape); 28 } 29 30 // Failure: No exception thrown for invalid escape char in this case. 31 try { 32 std::regex escape("\\a"); 33 assert(false); 34 } catch (std::regex_error &ex) { 35 assert(ex.code() == std::regex_constants::error_escape); 36 } 37 } 38