Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-05-10 04:17:29


----- Original Message -----
From: "Gennadiy Rozental" <rogeeff_at_[hidden]>

> "David Abrahams" <david.abrahams_at_[hidden]> wrote in message
> news:067001c1f7fc$302f73c0$8f01a8c0_at_boostconsulting.com...
>
> > You're testing assignability, which is a different question. Try:
> >
> > void f(A<B>);
> > int main()
> > {
> > f(A<C>());
> > }
> >
> > -Dave
>
> MSVC responce:
> error C2664: '__thiscall B::B(const struct B &)' : cannot convert
parameter
> 1 from 'const struct A<struct C>' to 'const struct B &'
> Reason: cannot convert from 'const struct A<struct C>' to 'const
> struct B'
> No constructor could take the source type, or constructor
overload
> resolution was ambiguous
> see reference to function template instantiation '__thiscall A<struct
> B>::A<struct B>(const struct A<struct C> &)' being compiled
>

Oh, now I see, your original definition of A's constructor makes this
illegal. I missed that, sorry. For reference:

template<typename T>
struct A : T
{
    A() {}
    template<class T1>
    A( A<T1> const& rhs ) : T( rhs ) {}
};

struct B {};
struct C {};

B and C are unrelated, so the constructor fails. I guess is_convertible is
misnamed, and should be called "will_be_considered_for_overload_resolution"
or something.

However, a fix may be possible using "the Paul Mensonides trick":
http://aspn.activestate.com/ASPN/Mail/Message/1182935

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk