|
Boost Users : |
Subject: [Boost-users] [Bind] Understanding protect
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2012-03-27 10:25:40
Hi All
I'd appreciate some helpful words about Boost.Bind protect, 'cos I'm not
quite understanding it!
I thought its purpose was allow binding, but not evaluating, of a function
object. So that this should
work.
#include <iostream>
#include <boost/bind.hpp>
#include <boost/bind/protect.hpp>
void f( int i ) { std::cout << i << std::endl; }
template <typename NullaryCallable> void g( const NullaryCallable &
callable ) { callable( ); }
int main( )
{
g( protect( bind( f, _1 ) )( 1 ) );
}
But it doesn't, and instead thinks I'm calling g() with the return type of
f(), just as if I'd not used protect at all.
Is it possible to have bind generate a fully bound, nullary callable object?
TIA,
- 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