common_type/iterator_traits is missing in C++14Section: 21.3.9.7 [meta.trans.other], 24.3.2.3 [iterator.traits] Status: C++17 Submitter: Daniel Krügler Opened: 2014-06-19 Last modified: 2017-07-30
Priority: Not Prioritized
View all other issues in [meta.trans.other].
View all issues with C++17 status.
Discussion:
During the Rapperswil meeting the proposal N4041 had been discussed and there seemed to be strong consensus to apply the SFINAE-friendly definitions that currently exist within the fundamentals-ts to the C++ Standard working draft. This issue requests this change to happen.
Proposed resolution:
This wording is relative to N3936.
Change 21.3.9.7 [meta.trans.other] p3 as indicated:
-3- For the
common_typetrait applied to a parameter packTof types, the membertypeshall be either defined or not present as follows:
If
sizeof...(T)is zero, there shall be no membertype.If
sizeof...(T)is one, letT0denote the sole type comprisingT. The member typedeftypeshall denote the same type asdecay_t<T0>.If
sizeof...(T)is greater than one, letT1,T2, andR, respectively, denote the first, second, and (pack of) remaining types comprisingT. [Note:sizeof...(R)may be zero. — end note] Finally, letCdenote the type, if any, of an unevaluated conditional expression (7.6.16 [expr.cond]) whose first operand is an arbitrary value of typebool, whose second operand is an xvalue of typeT1, and whose third operand is an xvalue of typeT2. If there is such a typeC, the member typedeftypeshall denote the same type, if any, ascommon_type_t<C,R...>. Otherwise, there shall be no membertype.The nested typedefcommon_type::typeshall be defined as follows:template <class ...T> struct common_type; template <class T> struct common_type<T> { typedef decay_t<T> type; }; template <class T, class U> struct common_type<T, U> { typedef decay_t<decltype(true ? declval<T>() : declval<U>())> type; }; template <class T, class U, class... V> struct common_type<T, U, V...> { typedef common_type_t<common_type_t<T, U>, V...> type; };
Change 24.3.2.3 [iterator.traits] p2 as indicated:
-2- The template
iterator_traits<Iterator>is defined asshall have the following as publicly accessible members, and have no other members, if and only ifIteratorhas valid (13.10.3 [temp.deduct]) member typesdifference_type,value_type,pointer,reference, anditerator_category; otherwise, the template shall have no members:namespace std { template<class Iterator> struct iterator_traits {typedef typename Iterator::difference_type difference_type; typedef typename Iterator::value_type value_type; typedef typename Iterator::pointer pointer; typedef typename Iterator::reference reference; typedef typename Iterator::iterator_category iterator_category;}; }