Boost logo

Boost Users :

Subject: [Boost-users] Writing an inline nullary function object?
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2010-12-01 12:46:38


How can I write an inline nullary function object, returning a fixed value?
The
equivalent of this...

int x = 4;

int f( ) { return x; }

boost::function<int()> g = f;

but without defining the intermediate f()?

I thought this might work...

boost::function<int()> g = bind(bind(apply<int>(), _1 ), x );

but maybe I've not got it quite right?

Thx

- Rob.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net