Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2003-10-11 09:23:06


Douglas Gregor wrote:
> On Saturday 11 October 2003 02:59 am, Firingme wrote:
>> I have a templated class named Point3D as following :
>>
>> template < typename T >
>> class Point3D
>> {
>> public:
>> typedef T PointType ;
>> Point3D* SetX(const T& x) { m_X = x ; return this ; }
>> Point3D* SetY(const T& y) { m_Y = y ; return this ; }
>> Point3D* SetZ(const T& z) { m_Z = z ; return this ; }
>>
>> T m_X,m_Y,m_Z ;
>> };
>>
>> Now, I want make a boost::function point to the fun: Point3D::SetX,
>> How can I write my code ?
>
> boost::function<Point3D<T>* (Point3D<T>& self, const T& x)> f
> = &Point3D<T>::SetX;

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 ?


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