basic_regex throws bad_cast with char32_t
问题 Why does the following code generate std::bad_cast exception? #include <iostream> #include <regex> #include <string> int main() { std::basic_string<char32_t> reg = U"^\\w"; try { std::basic_regex<char32_t> tagRegex(reg); } catch(std::exception &e) { std::cout << e.what() << std::endl; } return 0; } This sample on Ideone for convenience: https://ideone.com/Saea88 Using char or wchar instead of char32_t runs without throwing though (proof: https://ideone.com/OBlXed). 回答1: You can find here: