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 20 static bool error_escape_thrown(const char *pat) 21 { 22 bool result = false; 23 try { 24 std::regex re(pat); 25 } catch (const std::regex_error &ex) { 26 result = (ex.code() == std::regex_constants::error_escape); 27 } 28 return result; 29 } 30 31 int main() 32 { 33 assert(error_escape_thrown("[\\a]")); 34 assert(error_escape_thrown("\\a")); 35 36 assert(error_escape_thrown("[\\e]")); 37 assert(error_escape_thrown("\\e")); 38 39 assert(error_escape_thrown("[\\c:]")); 40 assert(error_escape_thrown("\\c:")); 41 assert(error_escape_thrown("\\c")); 42 assert(!error_escape_thrown("[\\cA]")); 43 assert(!error_escape_thrown("\\cA")); 44 45 } 46