Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2000-01-23 11:55:31


From: Valentin Bonnard <Bonnard.V_at_[hidden]>
> > > I propose (untested code):
> ...
> > > #define DEFINE_PSEUDO_CAST(THE_CAST) \
> > > template <typename To, typename From> \
> > > shared_ptr<To> do_ ## THE_CAST ## _cast (const shared_ptr<From>& p) \
> > > { \
> > > ++*p.pn; \
> > > return shared_ptr<To> (THE_CAST ## _cast<To*> (p.px), p.pn); \
> > > }
> > >
> > > DEFINE_PSEUDO_CAST(const)
> > > DEFINE_PSEUDO_CAST(static)
> >
> > I don't think the macros are worth the bother for such small
> > functions.
>
> Well, at first I had in mind the repetition of four time
> the same thing (static, dynamic, const, reinterpret). After
> I realised that there were only two repetitions.
>
> I currently use macros a lot.

I have no trouble with macros for factoring out implementation at
file scope, but don't like them in headers where they tromp on
the global namespace. At least they should be prefixed with
BOOST_ and undefined in the same header, but I still don't think
those above factor out enough code to be worth the trouble.

Anyway, we should add these cast templates to boost::shared_ptr.
If you want to please go ahead and do so. I'm too busy right now,
and I don't see any letup any time soon.

For genericity we should probably have versions of these that
operate on raw pointers as well.

Thanks.


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