I came across a problem when using libstdc ++ std :: any implementation with mingw across the border of a shared library. It creates std::bad_any_castwhere it clearly does not follow (I suppose).
I am using mingw-w64, gcc-7 and compiling code with -std = C ++ 1z.
Simplified code:
main.cpp:
#include <any>
#include <string>
void do_stuff_with_any(const std::any& obj);
int main()
{
do_stuff_with_any(std::string{"Hello World"});
}
lib.cpp:
It will be compiled into a shared library and linked to the executable from main.cpp.
#include <any>
#include <iostream>
void do_stuff_with_any(const std::any& obj)
{
std::cout << std::any_cast<const std::string&>(obj) << "\n";
}
std:: bad_any_cast, , do_stuff_with_any, . gcc , -, - (, ), , - ,
, -, .
std:: any ? UB -? gcc? , Linux, mingw? , -, ? () ?