meta: allow checking meta_any for nullptr (#591)

This commit is contained in:
Tom Yaxley
2020-11-20 19:32:53 +11:00
committed by Michele Caini
parent bc987ed03f
commit 7c0db3203b

View File

@@ -171,9 +171,11 @@ class meta_any {
using pointed_type = std::remove_reference_t<decltype(*std::declval<Type>())>;
if constexpr(std::is_const_v<pointed_type> && std::is_copy_constructible_v<pointed_type>) {
return std::as_const(*any.cast<Type>());
auto ptr = any.cast<Type>();
return ptr ? std::as_const(*ptr) : meta_any{};
} else if constexpr(!std::is_const_v<pointed_type>) {
return std::ref(*any.cast<Type>());
auto ptr = any.cast<Type>();
return ptr ? std::ref(*ptr) : meta_any{};
} else {
return {};
}