Boost logo

Boost Users :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2005-01-12 01:45:42


Tom Widmer writes:
> Aleksey Gurtovoy wrote:
>
> > Agoston Bejo writes:
> >
> >> Hello,
> >>
> >> how do I express through template metaprogramming or in a similar
> >> way that a class is convertible to a template class for some T1?
> >> I.e., the condition: "There exists some T1 such that B is
> >> convertible to A<T1>".
> >
> >
> >
> > Use overload resolution. The easiest way would probably be to take
> > 'is_convertible' implementation for your compiler and replace the
> > overload used to detect 'To' type convertibility with with a function
> > temlate accepting 'A<T1>'.
>
>
> But template argument deduction will fail, won't it, since user defined
> conversions aren't considered when deducing template arguments?

Yes, it will.

> Obviously, if the class is derived from A<T1> for some T1, then it
> should work, since the derived-to-base conversion is considered.

This was the case with the OP code, and what I was thinking of when I
wrote the above.

Thanks for the correction,

-- 
Aleksey Gurtovoy
MetaCommunications Engineering

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net