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>
|
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().
|
|
template<typename T>
struct etl::reference_wrapper< T >
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.
◆ type
◆ reference_wrapper() [1/2]
template<typename T>
template<typename U, typename = decltype(detail::FUN<T>(declval<U>()), enable_if_t<!is_same_v<reference_wrapper, remove_cvref_t<U>>>())>
◆ reference_wrapper() [2/2]
Constructs a new reference wrapper. Copy constructor. Stores a reference to other.get().
◆ get()
template<typename T>
auto get |
( |
| ) |
const -> type& |
|
inlinenodiscardconstexprnoexcept |
Returns the stored reference.
◆ operator type &()
template<typename T>
operator type & |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Returns the stored reference.
◆ operator()()
template<typename T>
template<typename... Args>
auto operator() |
( |
Args &&... | args | ) |
const -> invoke_result_t<T&, Args...>
|
|
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.
- Returns
- The return value of the called function.
◆ operator=()
Copy assignment operator. Drops the current reference and stores a reference to other.get().
The documentation for this struct was generated from the following file: