23 General utilities library [utilities]
23.14.5 Class template reference_wrapper [refwrap]
namespace std {
template <class T> class reference_wrapper {
public :
using type = T;
reference_wrapper(T&) noexcept;
reference_wrapper(T&&) = delete; reference_wrapper(const reference_wrapper& x) noexcept;
reference_wrapper& operator=(const reference_wrapper& x) noexcept;
operator T& () const noexcept;
T& get() const noexcept;
template <class... ArgTypes>
invoke_result_t<T&, ArgTypes...>
operator() (ArgTypes&&...) const;
};
template<class T>
reference_wrapper(reference_wrapper<T>) -> reference_wrapper<T>;
}
reference_wrapper<T> is a
CopyConstructible and
CopyAssignable wrapper
around a reference to an object or function of type
T. reference_wrapper<T> shall be a trivially copyable type (
[basic.types])
. reference_wrapper(T& t) noexcept;
Effects: Constructs a
reference_wrapper object that stores a
reference to
t. reference_wrapper(const reference_wrapper& x) noexcept;
Effects: Constructs a
reference_wrapper object that
stores a reference to
x.get(). reference_wrapper& operator=(const reference_wrapper& x) noexcept;
Postconditions: *this stores a reference to
x.get(). operator T& () const noexcept;
Returns: The stored reference
. T& get() const noexcept;
Returns: The stored reference
. template <class... ArgTypes>
invoke_result_t<T&, ArgTypes...>
operator()(ArgTypes&&... args) const;
Returns: INVOKE(get(), std::forward<ArgTypes>(args)...). template <class T> reference_wrapper<T> ref(T& t) noexcept;
Returns: reference_wrapper<T>(t). template <class T> reference_wrapper<T> ref(reference_wrapper<T> t) noexcept;
template <class T> reference_wrapper<const T> cref(const T& t) noexcept;
Returns: reference_wrapper <const T>(t). template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;