Re: Paradox in SFINAE with is_convertible
On 9/5/07 1:00 PM, in article
1189007826.628060.40440@22g2000hsm.googlegroups.com, "Richard Smith"
<richard@ex-parrot.com> wrote:
Consider the following class (into which I have put some debugging
statements).
struct C {
C() { printf( "C::C()\n" ); }
template <class T>
C( T const&,
typename disable_if< is_convertible<T, C> >::type* = 0 )
{ printf( "C::C(T const&)\n" ); }
};
For the sake of argument, disable_if and is_convertible can be the
ones from boost. On the face of it, this is requesting that C be
implicitly constructible from T (i.e. that T be implicitly convertible
to C) if and only if T is not convertible to C.
The is_convertible class template requires that both of its type arguments
be complete types (which makes sense because the full "convertiblity" of a
type can be evaluated only after all of its member functions, including its
constructors, have been declared). In this case, the "C" type parameter used
in the is_convertible<> template has an incomplete type (appearing as it
does in the parameter list of one of its own member functions). Therefore
the outcome of evaluating is_convertible<T, C> is not defined by the draft
C++ Standard.
Greg
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]