|
Boost : |
From: Edward Diener (eddielee_at_[hidden])
Date: 2003-10-11 13:42:27
Douglas Gregor wrote:
> On Saturday 11 October 2003 10:23 am, Edward Diener wrote:
>> In the documentation, this last would be:
>>
>> boost::function<Point3D<T>* (Point3D<T>* self, const T& x)> f =
>> &Point3D<T>::SetX;
>>
>> where the first parameter is a 'this' pointer rather than a '*this'
>> reference.
>>
>> Is boost::function<Point3D<T>* (Point3D<T>& self, const T& x)> f =
>> &Point3D<T>::SetX;
>>
>> also allowable with:
>>
>> int i(0);
>> Point3D<int> apoint;
>>
>> f(apoint,i);
>>
>> being valid ?
>
> Yup. You can even do this, if you want:
>
> boost::function<Point3D<T>* (boost::shared_ptr<Point3D<T> > self,
> const T& x)> f = &Point3D<T>::SetX;
Of course ! I expect no less <g>.
>
> Thank you mem_fn.
So as long as one passes in either a pointer, shared pointer, or reference
to the actual object as the first parameter, and defines boost::function
accordingly, it should work fine. Very nice ! Maybe you should update the
boost::function doc to show this, along with the plain pointer example, in
your tutorial.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk