Re: [Boost-bugs] [Boost C++ Libraries] #7251: is_convertible works incorrectly for rvalue source types

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7251: is_convertible works incorrectly for rvalue source types
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-08-31 01:12:11


#7251: is_convertible works incorrectly for rvalue source types
--------------------------------------+-------------------------------------
  Reporter: michel | Owner: johnmaddock
      Type: Patches | Status: new
 Milestone: To Be Determined | Component: type_traits
   Version: Boost Development Trunk | Severity: Problem
Resolution: | Keywords:
--------------------------------------+-------------------------------------

Comment (by michel):

 I have some questions.

 First, here is the description of `is_convertible` from the C++11
 Standard:

   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 following
 code would be well-formed, including any implicit conversions to the
 return type of the function:
 {{{
 To test() {
     return create<From>();
 }
 }}}
 [[BR]]

 In C++11, for a function type `Func`, `is_convertible<Func, Func&>`
 returns true_type. But, on gcc 4.5-4.6, `Func&&` cannot be convertible to
 `Func&`.
 My question is "What should `is_convertible<Func, Func&>` return on gcc
 4.5-4.6?"
 [[BR]][[BR]]

 Also, in C++03, what should `is_convertible<Func, Func*>` return?
 It would be reasonable to return true_type, since `is_convertible<Func,
 Func*>` returns true_type in C++11.
 But we can make another interpretation. Boost's interpretation of C++03
 `add_rvalue_reference<T>` is just returning `T`. Accordingly,
 `declval<T>()` returns a value of `T`. So,
 {{{
 template <class T>
 typename add_rvalue_reference<T>::type create();

 To test() {
     return create<From>();
 }
 }}}
 is ill-formed when `From` is a function type. With this interpretation,
 `is_convertible<Func, Func*>` should return false_type.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7251#comment:6>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC