Function forward_as_any
Synopsis
#include <src/entt/core/any.hpp>
template <std::size_t Len = basic_any<>::length, std::size_t Align = basic_any<Len>::alignment, typename Type>
basic_any< Len, Align > forward_as_any(Type &&value)
Description
Forwards its argument and avoids copies for lvalue references.
- Template Parameters
Len
- Size of the storage reserved for the small buffer optimization.Align
- Optional alignment requirement.Type
- Type of argument to use to construct the new instance.- Parameters
value
- Parameter to use to construct the instance.- Returns
- A properly initialized and not necessarily owning wrapper.
Mentioned in
- Core Functionalities / Any as in any type
- Entity Component System / A base class to rule them all
Source
Lines 483-486 in src/entt/core/any.hpp.
template<std::size_t Len = basic_any<>::length, std::size_t Align = basic_any<Len>::alignment, typename Type>
basic_any<Len, Align> forward_as_any(Type &&value) {
return basic_any<Len, Align>{std::in_place_type<std::conditional_t<std::is_rvalue_reference_v<Type>, std::decay_t<Type>, Type>>, std::forward<Type>(value)};
}