Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2004-07-09 10:57:13


Larry Evans wrote:
> [...]
> template <typename T>
> struct nested
> {
> template
> < typename S //subtype of T'
> >
> nested(sp<P1,P2>::nested<S>& a_sp)
> ;
> };
>
> Now both P1 and P2 are in a non-deduced context and, AFAICT,
> there no workaround using some helper class like the above
> nested_base or Brian's i_am_a_nested_thingy. Maybe I'm wrong.
> If so, could someone please outline a solution?

We (meaning Andrei and I, since it was his idea) cheated by using
an overly general template argument and hoping for the best. I.e.:

     template <class SP>
     nested(SP& sp, typename SP::nested_type = 0);

Where nested_type is just something we expect to find in SP. Of
course, this is not foolproof, and someone could break it. But
as you say, there is no foolproof solution in the current language
that I can see (at least not one that is lightweight enough to be
practical).

Dave


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