This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++20 status.
__cpp_lib_unwrap_ref in wrong headerSection: 17.3.2[version.syn], 99 [refwrap.unwrapref]Status:C++20Submitter: Barry RevzinOpened: 2019-12-03Last modified: 2021-02-25
Priority:2
View otheractive issues in [version.syn].
View all otherissues in [version.syn].
View all issues withC++20 status.
Discussion:
cpplearner points out inthis github comment that:
Since
unwrap_referenceandunwrap_ref_decayare defined in<functional>([functional.syn]), their feature test macro should also be defined there.
P1902R1 adds this feature test macro in<type_traits> instead. The feature test macro and the type traits should go into the same header: either both in<functional> or both in<type_traits>.
<functional>.[2019-12-12 Issue Prioritization]
Priority to 2 after reflector discussion.
Previous resolution [SUPERSEDED]:This wording is relative toN4842.
Modify 17.3.2[version.syn] p2 as indicated:
[…]#define __cpp_lib_unordered_map_try_emplace 201411L// also in <unordered_map>#define __cpp_lib_unwrap_ref 201811L// also in <type_traitsfunctional>#define __cpp_lib_variant 201606L// also in <variant>[…]
[2020-02-13, Prague]
During LWG discussions it had been suggested that they considered it is an improvement to move the definitions ofunwrap_reference andunwrap_ref_decay from<functional> to<type_traits>.This is what the alternative wording tries to accomplish.
[Status to Immediate on Thursday night in Prague.]
Proposed resolution:
This wording is relative toN4849.
Modify 22.10.2[functional.syn], header<functional> synopsis, as indicated:
namespace std {[…]template<class T> struct unwrap_reference;template<class T> using unwrap_reference_t = typename unwrap_reference<T>::type;template<class T> struct unwrap_ref_decay;template<class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type;[…]}Delete sub-clause 99 [refwrap.unwrapref] completely, as indicated:
20.14.5.6 Transformation type traitunwrap_reference[refwrap.unwrapref]template<class T> struct unwrap_reference;
-1- IfTis a specializationreference_wrapper<X>for some typeX, the member typedeftypeofunwrap_reference<T>isX&, otherwise it isT.template<class T> struct unwrap_ref_decay;
-2- The member typedeftypeofunwrap_ref_decay<T>denotes the typeunwrap_reference_t<decay_t<T>>.
Modify 21.3.3[meta.type.synop], header<type_traits> synopsis, as indicated:
namespace std {[…]// 21.3.9.7[meta.trans.other], other transformations[…]template<class T> struct underlying_type;template<class Fn, class... ArgTypes> struct invoke_result;template<class T> struct unwrap_reference;template<class T> struct unwrap_ref_decay;template<class T> using type_identity_t = typename type_identity<T>::type;[…]template<class Fn, class... ArgTypes> using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type;template<class T> using unwrap_reference_t = typename unwrap_reference<T>::type;template<class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type;template<class...> using void_t = void;[…]}Modify 21.3.9.7[meta.trans.other], Table 55 — "Sign modifications" in [tab:meta.trans.sign] as indicated:
| Template | Comments |
|---|---|
[…] | |
template <class T> | IfT is a specializationreference_wrapper<X> for some typeX, the member typedeftype ofunwrap_reference<T> isX&, otherwise it isT. |
template <class T> | The member typedeftype ofunwrap_ref_decay<T> denotes the typeunwrap_reference_t<decay_t<T>>. |
Insert between 21.3.9.7[meta.trans.other] p1 and p2 as indicated:
In addition to being available via inclusion of the
<type_traits>header, the templatesunwrap_reference,unwrap_ref_decay,unwrap_reference_t, andunwrap_ref_decay_tare available when the header<functional>(22.10.2[functional.syn]) is included.