When should I use std::any

When to Use void* as an extremely unsafe pattern with some limited use cases, std::any adds type-safety, and that’s why it has some real use cases. Some possibilities: In Libraries – when a library type has to hold or pass anything without knowing the set of available types. Parsing files – if you really cannot … Read more

C++ std::map holding ANY type of value

This is plain in C++ 17. Use std::map + std::any + std::any_cast: #include <map> #include <string> #include <any> int main() { std::map<std::string, std::any> notebook; std::string name{ “Pluto” }; int year = 2015; notebook[“PetName”] = name; notebook[“Born”] = year; std::string name2 = std::any_cast<std::string>(notebook[“PetName”]); // = “Pluto” int year2 = std::any_cast<int>(notebook[“Born”]); // = 2015 }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)