Created on 2009-01-25.00:00:00 last changed 144 months ago
Proposed resolution:
In [meta.rel] change:
Template Condition Comments ... ... ... template <class From, class To>
struct is_convertible;The code set out below shall be well formed.see belowFrom and To shall be complete types, arrays of unknown bound, or (possibly cv-qualified) void types. -4-
In order to instantiate the template is_convertible<From, To>, the following code shall be well formed:Given the following function prototype:template <class T> typename add_rvalue_reference<T>::type create();the predicate condition for a template specialization is_convertible<From, To> shall be satisfied, if and only if the return expression in the following code would be well-formed, including any implicit conversions to the return type of the function.
To test() { return create<From>(); }[Note: This requirement gives well defined results for reference types, void types, array types, and function types. — end note]
[ Batavia (2009-05): ]
We agree with the proposed resolution. Move to Tentatively Ready.
[ Post Summit, Howard adds: ]
John finds the following wording clearer:
Template Condition Comments template <class From, class To>
struct is_convertible;see below From and To shall be complete types, arrays of unknown bound, or (possibly cv-qualified) void types. Given the following function prototype:
template <class T> typename add_rvalue_reference<T>::type create();is_convertible<From, To>::value shall be true if the return expression in the following code would be well-formed, including any implicit conversions to the return type of the function, else is_convertible<From, To>::value shall be false.
To test() { return create<From>(); }
Original proposed wording:
In [meta.rel]/4 change:
In order to instantiate the template is_convertible<From, To>, the following code shall be well formedIf the following code is well formed is_convertible<From, To>::value is true, otherwise false:[..]
Revision 2
In [meta.rel] change:
Template Condition Comments ... ... ... template <class From, class To>
struct is_convertible;The code set out below shall be well formed.see belowFrom and To shall be complete types, arrays of unknown bound, or (possibly cv-qualified) void types. -4-
In order to instantiate the template is_convertible<From, To>, the following code shall be well formed:Given the following function prototype:template <class T> typename add_rvalue_reference<T>::type create();is_convertible<From, To>::value inherits either directly or indirectly from true_type if the return expression in the following code would be well-formed, including any implicit conversions to the return type of the function, else is_convertible<From, To>::value inherits either directly or indirectly from false_type.
To test() { return create<From>(); }[Note: This requirement gives well defined results for reference types, void types, array types, and function types. -- end note]
[ Post Summit: ]
Jens: Checking that code is well-formed and then returning true/false sounds like speculative compilation. John Spicer would really dislike this. Please find another wording suggesting speculative compilation.
Recommend Open.
Addresses UK 206
Related to 1114.
The current specification of std::is_convertible (reference is draft N2798) is basically defined by [meta.rel] p.4:
In order to instantiate the template is_convertible<From, To>, the following code shall be well formed:
template <class T> typename add_rvalue_reference<T>::type create(); To test() { return create<From>(); }[Note: This requirement gives well defined results for reference types, void types, array types, and function types. — end note]
The first sentence can be interpreted, that e.g. the expression
std::is_convertible<double, int*>::value
is ill-formed because std::is_convertible<double, int*> could not be instantiated, or in more general terms: The wording requires that std::is_convertible<X, Y> cannot be instantiated for otherwise valid argument types X and Y if X is not convertible to Y.
This semantic is both unpractical and in contradiction to what the last type traits paper N2255 proposed:
If the following test function is well formed code b is true, else it is false.
template <class T> typename add_rvalue_reference<T>::type create(); To test() { return create<From>(); }[Note: This definition gives well defined results for reference types, void types, array types, and function types. — end note]
History | |||
---|---|---|---|
Date | User | Action | Args |
2013-01-24 18:22:11 | admin | set | status: wp -> c++11 |
2010-10-21 18:28:33 | admin | set | messages: + msg4640 |
2010-10-21 18:28:33 | admin | set | messages: + msg4639 |
2010-10-21 18:28:33 | admin | set | messages: + msg4638 |
2010-10-21 18:28:33 | admin | set | messages: + msg4637 |
2009-01-25 00:00:00 | admin | create |