any: forward/centralize requests internally

This commit is contained in:
Michele Caini
2022-10-24 14:38:55 +02:00
parent b02e4efe4d
commit 2a01b78b32

View File

@@ -295,7 +295,7 @@ public:
* @return An opaque pointer the contained instance, if any.
*/
[[nodiscard]] void *data() noexcept {
return (!vtable || mode == policy::cref) ? nullptr : const_cast<void *>(vtable(operation::get, *this, nullptr));
return mode == policy::cref ? nullptr : const_cast<void *>(std::as_const(*this).data());
}
/**
@@ -304,7 +304,7 @@ public:
* @return An opaque pointer the contained instance, if any.
*/
[[nodiscard]] void *data(const type_info &req) noexcept {
return *info == req ? data() : nullptr;
return mode == policy::cref ? nullptr : const_cast<void *>(std::as_const(*this).data(req));
}
/**