decay
in reference_wrapper
Section: 22.10.6.2 [refwrap.const] Status: C++20 Submitter: Agustín K-ballo Bergé Opened: 2017-12-04 Last modified: 2021-02-25
Priority: 0
View all other issues in [refwrap.const].
View all issues with C++20 status.
Discussion:
Another occurrence of unnecessary decay (P0777) was introduced by the
resolution of LWG 2993. A decayed function/array type will never be the same type as
reference_wrapper
.
[ 2018-01-09 Moved to Tentatively Ready after 9 positive votes on c++std-lib. ]
[2018-3-17 Adopted in Jacksonville]
Proposed resolution:
This wording is relative to N4713.
Change 22.10.6.2 [refwrap.const] as indicated:
template<class U> reference_wrapper(U&& u) noexcept(see below);-1- Remarks: Let
FUN
denote the exposition-only functionsvoid FUN(T&) noexcept; void FUN(T&&) = delete;This constructor shall not participate in overload resolution unless the expression
FUN(declval<U>())
is well-formed andis_same_v<
isdecay_tremove_cvref_t<U>, reference_wrapper>false
. The expression insidenoexcept
is equivalent tonoexcept(FUN(declval<U>()))
.