Re: [Boost-users] B is_convertible to A<T> for some T

John Maddock writes:
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>". An example program: (Platform: VC++7.1)
I guess you want the type-trait: is_convertible<from, to>.
In his case, 'to' is an unbound family of types ('A<X>' for any 'X'), so 'is_convertible' won't do it. May be we should consider getting this in the library, in some form. E.g. tweak 'is_convertible' to support something like is_convertible<from, A<_> > -- Aleksey Gurtovoy MetaCommunications Engineering

Aleksey Gurtovoy wrote:
In his case, 'to' is an unbound family of types ('A<X>' for any 'X'), so 'is_convertible' won't do it. May be we should consider getting this in the library, in some form. E.g. tweak 'is_convertible' to support something like
is_convertible<from, A<_> >
Or something like exists<_1, /* such that */ is_convertible<from, A<_1> > ;//-) Quite often, I suppose, is enough to specify a sequence of candidate types and then call mpl::find_if<candidates, is_convertible<from, A<_> > > (It would be very funny to generalize mpl sequence concept to support infinite sequences of unknown elements to cover this case :-))) -- Alexander Nasonov

Alexander Nasonov wrote:
(It would be very funny to generalize mpl sequence concept to support infinite sequences of unknown elements to cover this case :-)))
?? The sequence concept already supports that. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

David Abrahams wrote:
Alexander Nasonov wrote:
(It would be very funny to generalize mpl sequence concept to support infinite sequences of unknown elements to cover this case :-)))
?? The sequence concept already supports that.
It was a stupid idea. Forget it. -- Alexander Nasonov
participants (3)
-
Aleksey Gurtovoy
-
Alexander Nasonov
-
David Abrahams