Function meta_invoke

Summary

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

(1) template <typename Type, typename Policy = as_is_t, typename Candidate>
    meta_any meta_invoke([[maybe_unused]] meta_handle instance, Candidate &&candidate, [[maybe_unused]] meta_any *const args)

(2) template <typename Type, auto Candidate, typename Policy = as_is_t>
    meta_any meta_invoke(meta_handle instance, meta_any *const args)

Function overload

Synopsis

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

template <typename Type, typename Policy = as_is_t, typename Candidate>
meta_any meta_invoke([[maybe_unused]] meta_handle instance, Candidate &&candidate, [[maybe_unused]] meta_any *const args)

Description

Invokes a callable object given a list of erased parameters, if possible.

Template Parameters

Type - Reflected type to which the callable object is associated.

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

Candidate - The type of the actual callable object to invoke.

Parameters

instance - An opaque instance of the underlying type, if required.

candidate - The actual callable object to invoke.

args - Parameters to use to invoke the callable object.

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

Source

Lines 325-337 in src/entt/meta/utility.hpp.

template<typename Type, typename Policy = as_is_t, typename Candidate>
[[nodiscard]] meta_any meta_invoke([[maybe_unused]] meta_handle instance, Candidate &&candidate, [[maybe_unused]] meta_any * const args) {
    if constexpr(std::is_invocable_v<std::remove_reference_t<Candidate>>) {
        if constexpr(std::is_void_v<decltype(std::forward<Candidate>(candidate)())>) {
            std::forward<Candidate>(candidate)();
            return meta_any{std::in_place_type<void>};
        } else {
            return meta_dispatch<Policy>(std::forward<Candidate>(candidate)());
        }
    } else {
        return internal::meta_invoke<Type, Policy>(std::move(instance), std::forward<Candidate>(candidate), args, std::make_index_sequence<meta_function_helper_t<Type, std::remove_reference_t<Candidate>>::args_type::size>{});
    }
}

Synopsis

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

template <typename Type, auto Candidate, typename Policy = as_is_t>
meta_any meta_invoke(meta_handle instance, meta_any *const args)

Description

Invokes a function given a list of erased parameters, if possible.

Template Parameters

Type - Reflected type to which the function is associated.

Candidate - The actual function to invoke.

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

Parameters

instance - An opaque instance of the underlying type, if required.

args - Parameters to use to invoke the function.

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

Source

Lines 349-352 in src/entt/meta/utility.hpp.

template<typename Type, auto Candidate, typename Policy = as_is_t>
[[nodiscard]] meta_any meta_invoke(meta_handle instance, meta_any * const args) {
    return meta_invoke<Type, Policy>(std::move(instance), Candidate, args);
}





Add Discussion

Log in to comment