Boost logo

Boost :

From: Ed Brey (edbrey_at_[hidden])
Date: 2001-08-07 12:27:13


From: "Douglas Gregor" <gregod_at_[hidden]>
> > If the template type deduction is ever different from what you want,
you
> > can always specify the template parameters yourself. Yes, more
typing,
> > but no worse than putting the same in the constructor of the
> > hand-written version.
>
> For a constructor?

Oops, you're right. The constructor can only deduce the types since the
<type1,type2> syntax is reserved for the class template parameters, if
any, rather than the member (constructor) template parameters. So if
the user didn't like the default deduced type, he has to revert to
static casting to get the desired type to use base_from_member.

Considering the issues with argument passing to the constructor and the
naming restriction on the member variable, there are certainly use cases
in which the base_from_member class is not appropriate. Of course, no
one is proposing that is used wherever possible. So long as it is
useful a reasonable percentage of the time, it is worth putting into a
programmer's toolbox.


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