|
|
@@ -157,39 +157,41 @@ private:
|
|
|
|
|
|
/*! @brief Opaque wrapper for values of any type. */
|
|
|
class meta_any {
|
|
|
- using vtable_type = void(const internal::meta_traits, const meta_ctx &, void *, const void *, void *);
|
|
|
+ using vtable_type = void(const internal::meta_traits, const meta_ctx &, const void *, void *);
|
|
|
|
|
|
template<typename Type>
|
|
|
- static void basic_vtable([[maybe_unused]] const internal::meta_traits req, [[maybe_unused]] const meta_ctx &area, [[maybe_unused]] void *value, [[maybe_unused]] const void *as_const, [[maybe_unused]] void *other) {
|
|
|
+ static void basic_vtable([[maybe_unused]] const internal::meta_traits req, [[maybe_unused]] const meta_ctx &area, [[maybe_unused]] const void *value, [[maybe_unused]] void *other) {
|
|
|
static_assert(std::is_same_v<std::remove_const_t<std::remove_reference_t<Type>>, Type>, "Invalid type");
|
|
|
|
|
|
if constexpr(is_meta_pointer_like_v<Type>) {
|
|
|
if(req == internal::meta_traits::is_pointer_like) {
|
|
|
if constexpr(std::is_function_v<typename std::pointer_traits<Type>::element_type>) {
|
|
|
- static_cast<meta_any *>(other)->emplace<Type>(*static_cast<const Type *>(as_const));
|
|
|
+ static_cast<meta_any *>(other)->emplace<Type>(*static_cast<const Type *>(value));
|
|
|
} else if constexpr(!std::is_void_v<std::remove_const_t<typename std::pointer_traits<Type>::element_type>>) {
|
|
|
using in_place_type = decltype(adl_meta_pointer_like<Type>::dereference(std::declval<const Type &>()));
|
|
|
|
|
|
if constexpr(std::is_constructible_v<bool, Type>) {
|
|
|
- if(const auto &pointer_like = *static_cast<const Type *>(as_const); pointer_like) {
|
|
|
+ if(const auto &pointer_like = *static_cast<const Type *>(value); pointer_like) {
|
|
|
static_cast<meta_any *>(other)->emplace<in_place_type>(adl_meta_pointer_like<Type>::dereference(pointer_like));
|
|
|
}
|
|
|
} else {
|
|
|
- static_cast<meta_any *>(other)->emplace<in_place_type>(adl_meta_pointer_like<Type>::dereference(*static_cast<const Type *>(as_const)));
|
|
|
+ static_cast<meta_any *>(other)->emplace<in_place_type>(adl_meta_pointer_like<Type>::dereference(*static_cast<const Type *>(value)));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if constexpr(is_complete_v<meta_sequence_container_traits<Type>>) {
|
|
|
- if(req == internal::meta_traits::is_sequence_container) {
|
|
|
- *static_cast<meta_sequence_container *>(other) = (value == nullptr) ? meta_sequence_container{area, *static_cast<const Type *>(as_const)} : meta_sequence_container{area, *static_cast<Type *>(value)};
|
|
|
+ if(!!(req & internal::meta_traits::is_sequence_container)) {
|
|
|
+ // NOLINTNEXTLINE(bugprone-casting-through-void)
|
|
|
+ *static_cast<meta_sequence_container *>(other) = !!(req & internal::meta_traits::is_const) ? meta_sequence_container{area, *static_cast<const Type *>(value)} : meta_sequence_container{area, *static_cast<Type *>(const_cast<void *>(value))};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if constexpr(is_complete_v<meta_associative_container_traits<Type>>) {
|
|
|
- if(req == internal::meta_traits::is_associative_container) {
|
|
|
- *static_cast<meta_associative_container *>(other) = (value == nullptr) ? meta_associative_container{area, *static_cast<const Type *>(as_const)} : meta_associative_container{area, *static_cast<Type *>(value)};
|
|
|
+ if(!!(req & internal::meta_traits::is_associative_container)) {
|
|
|
+ // NOLINTNEXTLINE(bugprone-casting-through-void)
|
|
|
+ *static_cast<meta_associative_container *>(other) = !!(req & internal::meta_traits::is_const) ? meta_associative_container{area, *static_cast<const Type *>(value)} : meta_associative_container{area, *static_cast<Type *>(const_cast<void *>(value))};
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -531,15 +533,15 @@ public:
|
|
|
* @return A sequence container proxy for the underlying object.
|
|
|
*/
|
|
|
[[nodiscard]] meta_sequence_container as_sequence_container() noexcept {
|
|
|
- meta_sequence_container proxy{};
|
|
|
- if(vtable != nullptr) { vtable(internal::meta_traits::is_sequence_container, *ctx, storage.data(), std::as_const(storage).data(), &proxy); }
|
|
|
+ meta_sequence_container proxy = (storage.policy() == any_policy::cref) ? std::as_const(*this).as_sequence_container() : meta_sequence_container{};
|
|
|
+ if(!proxy && vtable != nullptr) { vtable(internal::meta_traits::is_sequence_container, *ctx, storage.data(), &proxy); }
|
|
|
return proxy;
|
|
|
}
|
|
|
|
|
|
/*! @copydoc as_sequence_container */
|
|
|
[[nodiscard]] meta_sequence_container as_sequence_container() const noexcept {
|
|
|
meta_sequence_container proxy{};
|
|
|
- if(vtable != nullptr) { vtable(internal::meta_traits::is_sequence_container, *ctx, nullptr, storage.data(), &proxy); }
|
|
|
+ if(vtable != nullptr) { vtable(internal::meta_traits::is_sequence_container | internal::meta_traits::is_const, *ctx, storage.data(), &proxy); }
|
|
|
return proxy;
|
|
|
}
|
|
|
|
|
|
@@ -548,15 +550,15 @@ public:
|
|
|
* @return An associative container proxy for the underlying object.
|
|
|
*/
|
|
|
[[nodiscard]] meta_associative_container as_associative_container() noexcept {
|
|
|
- meta_associative_container proxy{};
|
|
|
- if(vtable != nullptr) { vtable(internal::meta_traits::is_associative_container, *ctx, storage.data(), std::as_const(storage).data(), &proxy); }
|
|
|
+ meta_associative_container proxy = (storage.policy() == any_policy::cref) ? std::as_const(*this).as_associative_container() : meta_associative_container{};
|
|
|
+ if(!proxy && vtable != nullptr) { vtable(internal::meta_traits::is_associative_container, *ctx, storage.data(), &proxy); }
|
|
|
return proxy;
|
|
|
}
|
|
|
|
|
|
/*! @copydoc as_associative_container */
|
|
|
[[nodiscard]] meta_associative_container as_associative_container() const noexcept {
|
|
|
meta_associative_container proxy{};
|
|
|
- if(vtable != nullptr) { vtable(internal::meta_traits::is_associative_container, *ctx, nullptr, storage.data(), &proxy); }
|
|
|
+ if(vtable != nullptr) { vtable(internal::meta_traits::is_associative_container | internal::meta_traits::is_const, *ctx, storage.data(), &proxy); }
|
|
|
return proxy;
|
|
|
}
|
|
|
|
|
|
@@ -567,7 +569,7 @@ public:
|
|
|
*/
|
|
|
[[nodiscard]] meta_any operator*() const noexcept {
|
|
|
meta_any ret{meta_ctx_arg, *ctx};
|
|
|
- if(vtable != nullptr) { vtable(internal::meta_traits::is_pointer_like, *ctx, nullptr, storage.data(), &ret); }
|
|
|
+ if(vtable != nullptr) { vtable(internal::meta_traits::is_pointer_like, *ctx, storage.data(), &ret); }
|
|
|
return ret;
|
|
|
}
|
|
|
|