Boost logo

Boost :

From: Rene Jager (renej_at_[hidden])
Date: 2001-07-14 06:58:16


Peter Dimov wrote:

> I've updated bind.hpp. It now supports member function pointers and
> accept()s visitors. :-)
>
> Feedback is appreciated, as usual.

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(); }
};

and for a locking smart pointer LSP<X>:

template <typename X>
struct mf_deref_traits<LSP<X> >
{
   static LSP<X>::deref_type ptr (const LSP<X> & x) { return x.get(); }
        // 'LSP::deref_type' handles operator() with locking
};

and the default:

template <typename T>
struct mf_deref_traits
{
    static T * ptr (T * x) { return x; }
};

ignore any strange naming; it was to give an idea
the code above won't compile anyway... ;-)
I propose this because I use smart pointers which do lock an object on
dereferncing, including
calling member functions (overloaded operator->*())
perhaps a nice add-on for configurable smart pointers when
Boost.Threads is available?

renej

>
>
> --
> Peter Dimov
> Multi Media Ltd.
>
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
>
>
>
>


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