How to handle or avoid exceptions from C++11 <regex> matching functions (§28.11)?

Viewed 2749

Starting from C++11 the <regex> headers defines the functions std::regex_match, std::regex_search and std::regex_replace in §28.11. I guess there is a valid reason for these functions not to be noexcept, but I couldn't find any reference about what these might throw or why.

  1. What types of exceptions may these functions throw?
  2. What runtime conditions cause these exceptions to be thrown?
    • Does the standard ensure that for some sets of arguments these functions never throw, e.g. does it ensure that regex_match(anyString, regex(".")) never throws?

PS: Since some of these exceptions probably inherit from std::runtime_error, they might throw std::bad_alloc during their construction.

5 Answers
Related