Function construct

Summary

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

(1) meta_any construct(meta_any *const args, const size_type sz) const

(2) template <typename... Args>
    meta_any construct(Args &&... args) const

Function overload

Synopsis

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

meta_any construct(meta_any *const args, const size_type sz) const

Description

Creates an instance of the underlying type, if possible.

To create a valid instance, the parameters must be such that a cast or conversion to the required types is possible. Otherwise, an empty and thus invalid wrapper is returned.

Parameters

args - Parameters to use to construct the instance.

sz - Number of parameters to use to construct the instance.

Returns
A meta any containing the new instance, if any.

Source

Lines 1392-1400 in src/entt/meta/meta.hpp.

[[nodiscard]] meta_any construct(meta_any * const args, const size_type sz) const {
    meta_any any{};
    internal::find_if<&node_type::ctor>([args, sz, &any](const auto *curr) {
        return (curr->size == sz) && (any = curr->invoke(args));
    }, node);
    return any;
}

Synopsis

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

template <typename... Args>
meta_any construct(Args &&... args) const

Description

Creates an instance of the underlying type, if possible.

See
construct
Template Parameters

Args - Types of arguments to use to construct the instance.

Parameters

args - Parameters to use to construct the instance.

Returns
A meta any containing the new instance, if any.

Source

Lines 1411-1415 in src/entt/meta/meta.hpp.

template<typename... Args>
[[nodiscard]] meta_any construct(Args &&... args) const {
    std::array<meta_any, sizeof...(Args)> arguments{std::forward<Args>(args)...};
    return construct(arguments.data(), sizeof...(Args));
}





Add Discussion

Log in to comment