From cppreference.com
template<classT>typenamestd::decay<T>::type/*decay-copy*/(T&&value);(since C++11)
(until C++20)
(exposition only*)template<classT>requiresstd::convertible_to<T,std::decay_t<T>>constexprstd::decay_t<T>/*decay-copy*/(T&&value)noexcept(std::is_nothrow_convertible_v<T,std::decay_t<T>>);(since C++20)
(exposition only*)Returns std::forward<T>(value) (implicitly converted to the decayed type), a decayed prvalue copy of value.
Parameters
value - the value to be copied Return value
A decayed copy of value as a prvalue.
Notes
decay-copy was introduced by the resolution of
. It is initially used in the
to ensure that arguments are decayed when passing-by-value, and is later used in the
.
The language feature
(x) introduced in C++23 also allows decayed copies to be created as prvalues. The only difference is that decay-copy always
value and produces a copy, while auto(expr) is a no-op if expr is a prvalue.
All usages of decay-copy in the standard library (see below) except
,
and
are replaced with auto(x) since C++23.
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior
C++20 decay-copy was not constrained constrained See also
constructs new thread object
(public member function of std::thread)
constructs new jthread object
(public member function of std::jthread)
(C++11)
runs a function asynchronously (potentially in a new thread) and returns a
that will hold the result
(function template)
(C++20)
returns an iterator to the beginning of a range
(customization point object)
(C++20)
returns a sentinel indicating the end of a range
(customization point object)
(C++20)
returns a reverse iterator to a range
(customization point object)
(C++20)
returns a reverse end iterator to a range
(customization point object)
(C++20)
returns an integer equal to the size of a range
(customization point object)
(C++20)
obtains a pointer to the beginning of a contiguous range
(customization point object)
(C++20)
a
that includes all elements of a
(alias template)(range adaptor object)
(C++20)
a
consisting of the first N elements of another
(class template)(range adaptor object)
(C++20)
a
consisting of elements of another
, skipping the first N elements
(class template)(range adaptor object)