Function meta_dispatch

Synopsis

#include <src/entt/meta/utility.hpp>

template <typename Policy = as_is_t, typename Type>
meta_any meta_dispatch([[maybe_unused]] Type &&value)

Description

Wraps a value depending on the given policy.

Template Parameters

Policy - Optional policy (no policy set by default).

Type - Type of value to wrap.

Parameters

value - Value to wrap.

Returns
A meta any containing the returned value, if any.

Source

Lines 131-144 in src/entt/meta/utility.hpp.

template<typename Policy = as_is_t, typename Type>
meta_any meta_dispatch([[maybe_unused]] Type &&value) {
    if constexpr(std::is_same_v<Policy, as_void_t>) {
        return meta_any{std::in_place_type<void>};
    } else if constexpr(std::is_same_v<Policy, as_ref_t>) {
        return meta_any{std::in_place_type<Type>, std::forward<Type>(value)};
    } else if constexpr(std::is_same_v<Policy, as_cref_t>) {
        static_assert(std::is_lvalue_reference_v<Type>, "Invalid type");
        return meta_any{std::in_place_type<const std::remove_reference_t<Type> &>, std::as_const(value)};
    } else {
        static_assert(std::is_same_v<Policy, as_is_t>, "Policy not supported");
        return meta_any{std::forward<Type>(value)};
    }
}





Add Discussion

Log in to comment