registry: avoid embedding asserts with return expressions

This commit is contained in:
Michele Caini
2021-03-25 11:13:50 +01:00
parent d5e7005edd
commit bd648c0745

View File

@@ -1535,14 +1535,16 @@ public:
template<typename Type>
[[nodiscard]] Type & ctx() const {
auto it = std::find_if(vars.cbegin(), vars.cend(), [type = type_id<Type>()](auto &&var) { return var.type() == type; });
return (ENTT_ASSERT(it != vars.cend()), any_cast<Type &>(*it));
ENTT_ASSERT(it != vars.cend());
return any_cast<Type &>(*it);
}
/*! @copydoc ctx */
template<typename Type>
[[nodiscard]] Type & ctx() {
auto it = std::find_if(vars.begin(), vars.end(), [type = type_id<Type>()](auto &&var) { return var.type() == type; });
return (ENTT_ASSERT(it != vars.end()), any_cast<Type &>(*it));
ENTT_ASSERT(it != vars.end());
return any_cast<Type &>(*it);
}
/**