|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-07-14 07:21:44
From: "Rene Jager" <renej_at_[hidden]>
> is it possible to have the [c]mf[1-9] classes use a traits class to get
> a "raw" pointer?
> in the current impementation, for every "smart" pointer type a
> modification of the class is needed;
> proposal, something like:
>
> R operator () (T & x, args) const { return
> (mf_deref_traits<T>::ptr(x)->*f_)(args); }
>
> and
>
> R operator () (T * x, args) const { return
> (mf_deref_traits<T>::ptr(x)->*f_)(args); }
>
> where for shared_ptr<X> one can provide
>
> template <typename X>
> struct mf_deref_traits<shared_ptr<X> >
> {
> static X * ptr (const shared_ptr<X> & x) { return x.get(); }
> };
[...]
Yes, this is possible. There are two main problems with this approach that I
can see:
* MSVC compatibility. mf_deref_traits<shared_ptr<X> > is a partial
specialization. There'll also be problems with the overload resolution
between the various operator()s (it would likely require partial ordering.)
* Const correctness. Sometimes the constness of the smart pointer affects
the constness of the contained object, and sometimes it does not.
I'll think about this some more.
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk