Мой код выглядит следующим образом:
Код: Выделить всё
struct foo { ... };
std::any f() {
std::any obj;
obj = foo{};
return obj;
}
Код: Выделить всё
struct foo { ... };
std::any f() {
std::any obj;
obj = foo{};
assert(obj.type().hash_code() == typeid(foo).hash_code());
return obj;
}
Аналогично, и неожиданно, std::any_cast(&obj) возвращает nullptr.
Однако имя, возвращаемое любыми::type().name() и typeid(foo).name(), совпадает.Что я пропал?
Подробнее здесь: https://stackoverflow.com/questions/793 ... thash-code