Category : any

I wrote the code below, std::unordered_map<std::string_view, std::any> symbols_; symbols_["foo"] = dlsym(handle_), "foo"); When i use any_cast return (std::any_cast<void(*)()>(symbols_["foo"]))();, the program will throw a error: bad any_cast. I found the main reason because of the function . template<typename _Tp> void* __any_caster(const any* __any) It would judge the condition as false and then return nullptr. else if ..

Read more