tetl 0.1.0
Embedded Template Library
|
reference_wrapper is a class template that wraps a reference in a copyable, assignable object. It is frequently used as a mechanism to store references inside standard containers (like etl::static_vector) which cannot normally hold references. Specifically, reference_wrapper is a CopyConstructible and CopyAssignable wrapper around a reference to object or reference to function of type T. Instances of reference_wrapper are objects (they can be copied or stored in containers) but they are implicitly convertible to T&, so that they can be used as arguments with the functions that take the underlying type by reference. If the stored reference is Callable, reference_wrapper is callable with the same arguments. More...
#include <reference_wrapper.hpp>
Public Types | |
using | type = T |
Public Member Functions | |
constexpr | reference_wrapper (reference_wrapper const &x) noexcept=default |
Constructs a new reference wrapper. Copy constructor. Stores a reference to other.get(). | |
template<typename U , typename = decltype(detail::FUN<T>(declval<U>()), enable_if_t<!is_same_v<reference_wrapper, remove_cvref_t<U>>>())> | |
constexpr | reference_wrapper (U &&u) noexcept(noexcept(detail::FUN< T >(etl::forward< U >(u)))) |
Constructs a new reference wrapper. Converts x to T& as if by T& t = etl::forward(x);, then stores a reference to t. This overload only participates in overload resolution if decay_t<U> is not the same type as reference_wrapper and the expression FUN(declval<U>()) is well-formed, where FUN names the set of imaginary functions: | |
constexpr auto | get () const noexcept -> type & |
Returns the stored reference. | |
constexpr | operator type & () const noexcept |
Returns the stored reference. | |
template<typename... Args> | |
constexpr auto | operator() (Args &&... args) const noexcept(noexcept(invoke(get(), etl::forward< Args >(args)...))) -> invoke_result_t< T &, Args... > |
Calls the Callable object, reference to which is stored. This function is available only if the stored reference points to a Callable object. T must be a complete type. | |
constexpr auto | operator= (reference_wrapper const &x) noexcept -> reference_wrapper &=default |
Copy assignment operator. Drops the current reference and stores a reference to other.get(). | |
reference_wrapper is a class template that wraps a reference in a copyable, assignable object. It is frequently used as a mechanism to store references inside standard containers (like etl::static_vector) which cannot normally hold references. Specifically, reference_wrapper is a CopyConstructible and CopyAssignable wrapper around a reference to object or reference to function of type T. Instances of reference_wrapper are objects (they can be copied or stored in containers) but they are implicitly convertible to T&, so that they can be used as arguments with the functions that take the underlying type by reference. If the stored reference is Callable, reference_wrapper is callable with the same arguments.
|
inlineconstexprnoexcept |
Constructs a new reference wrapper. Converts x to T& as if by T& t = etl::forward(x);, then stores a reference to t. This overload only participates in overload resolution if decay_t<U>
is not the same type as reference_wrapper and the expression FUN(declval<U>())
is well-formed, where FUN names the set of imaginary functions:
https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper/reference_wrapper
|
constexprdefaultnoexcept |
Constructs a new reference wrapper. Copy constructor. Stores a reference to other.get().
Returns the stored reference.
Returns the stored reference.
|
inlineconstexprnoexcept |
Calls the Callable object, reference to which is stored. This function is available only if the stored reference points to a Callable object. T must be a complete type.
|
constexprdefaultnoexcept |
Copy assignment operator. Drops the current reference and stores a reference to other.get().