diff --git a/include/xo/facet/OObject.hpp b/include/xo/facet/OObject.hpp index 234a84d..6d14cf9 100644 --- a/include/xo/facet/OObject.hpp +++ b/include/xo/facet/OObject.hpp @@ -233,7 +233,7 @@ namespace xo { * Provided when actual type of @ref data_ is not DRepr, * because DRepr is DVariantPlaceholder. * - * We can't rely on dynamic_cast here, because DRepr's + * NOTE: We can't rely on dynamic_cast here, because DRepr's * don't need to be related as far as c++ type system is * concerned. **/ @@ -241,9 +241,14 @@ namespace xo { DOther * downcast() const requires (std::is_same_v) { - if (data_ && (typeseq::id() == this->iface()->_typeseq())) { + if constexpr (std::is_same_v) { + /* trivialconversion from type-erased to type-erased. + * Don't need to inspect runtime type + */ + return data_; + } else if (data_ && (typeseq::id() == this->iface()->_typeseq())) { /* actual runtime type for data_ is DOther, - * safe to reinterpret + * reported by _typseq() -> safe to reinterpret */ return reinterpret_cast(data_); } else {