registry: removed unnecessary dispatching from non-const try_ctx

This commit is contained in:
Michele Caini
2021-12-27 15:54:49 +01:00
parent 8eaf11b510
commit ccaa490a2f

View File

@@ -1497,12 +1497,8 @@ public:
/*! @copydoc try_ctx */
template<typename Type>
[[nodiscard]] Type *try_ctx() {
if constexpr(std::is_const_v<Type>) {
return std::as_const(*this).template try_ctx<Type>();
} else {
auto it = vars.find(type_hash<std::remove_const_t<std::remove_reference_t<Type>>>::value());
return it == vars.end() ? nullptr : any_cast<Type>(&it->second);
}
auto it = vars.find(type_hash<std::remove_const_t<std::remove_reference_t<Type>>>::value());
return it == vars.end() ? nullptr : any_cast<Type>(&it->second);
}
/**