Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-05-05 11:49:17

Justinas V.D. wrote:
> Question to Peter Dimov. Is it possible and rational to modify code in
> mem_fn_template.hpp so that
> get_pointer(u) would be called as get_pointer<U>(u) ?
> I believe this should not brake existing code, on the other hand, it
> would be easier to provide so-needed get_pointer overloads.

It will break, at minimum, all get_pointer overloads that are not templates.

> Actually, my problem is:
> I have, say, type T, and I'd like to write an implicit converter to
> templatized type Y so that:
> T::value_type * get_pointer(const Y<T> &p). Of course, all required
> enable_ifs are applied so that this overload is not visible for other
> types that do not meet some certain archetype.
> Then invocation of function get_pointer would create temporary object
> of type Y<T> which would be destroyed on exit from method call scope.
> That would be fine because in my case, Y c-tor locks mutex and d-tor -
> unlocks mutex.

You can use

    my_locking_ptr<T> get_pointer(T & t);

Of course my_locking_ptr<> must support operator->* for this to work.

Boost list run by bdawes at, gregod at, cpdaniel at, john at