Steven,
On 03/09/2011 06:11 AM, Sebastian Theophil wrote:
How can I write a lambda expression with two placeholders, one for
callable object, and one for the function argument, such that
supplying the callable object first returns a unary function?
In this case, boost::lambda::_1 by itself does what you want, because
the
the
callable object itself is a unary function.
That is true of course, I was trying to solve a slightly more
complicated problem though. I have solved the problem finally, although
I hoped there was a more elegant solution:
struct FCreateBind {
typedef boost::_bi::bind_t, boost::arg<2> > > result_type;
result_type operator()( Callable const& c ) const {
return boost::bind<bool>(c, _1);
}
};
BOOST_AUTO(generate, boost::bind(FCreateBind(), _1));
BOOST_AUTO(fn, generate(Callable());
bool b = fn(Arg());
Of course, in this simple example I could just write
BOOST_AUTO(generate, boost::lambda::_1) since Callable itself is the
callable object. But I was looking for a way to set the arguments of
Callable beforehand so the generated function fn is a nullary function.
This solution would let me do this inside FCreateBind.
FCreateBind can probably be eliminated as well, but I have not yet
figured out how to define the pointer to the overloaded global function
boost::bind.
Regards
Sebastian
--
Sebastian Theophil | stheophil@think-cell.com
Senior Software Engineer
think-cell Software GmbH | Chausseestr. 8/E | 10115 Berlin | Germany
http://www.think-cell.com | phone +49 30 666473-10 | US phone +1 800 891 8091
Amtsgericht Berlin-Charlottenburg, HRB 85229 | European Union VAT Id DE813474306
Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl