Get the size of std::any
问题 Is there any way to get the size (in bytes) of the data stored by std::any ? The only workaround I came up with is querying the type of its value by std::any::type and comparing the result to a list of known types like my_any.type() == typeid(T) , then the size is sizeof(T) . Unfortunately, this solution only works when the types are known beforehand. Do you know any solution? 回答1: You cannot get the size of the object held by std::any (other than the workaround you've mentioned). std::any is