mardi 22 septembre 2020

Can I use the STL regex library on strings of char16_t?

In short, what is inherently wrong with the following code?

#include <regex>
int main() {
    std::regex_match(u" ", std::basic_regex<char16_t>{u" "});
}

It errors with

$ g++ -std=c++17 main.cpp -o main
$ ./main
terminate called after throwing an instance of 'std::bad_cast'
  what():  std::bad_cast
Aborted (core dumped)

More info:

$ g++ --version                                                                                                                                                                                                                                    
g++ (GCC) 10.2.0                                                                                                                                                                                                                                               
Copyright (C) 2020 Free Software Foundation, Inc.                                                                                                                                                                                                              
This is free software; see the source for copying conditions.  There is NO                                                                                                                                                                                     
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Aucun commentaire:

Enregistrer un commentaire