On Tue, Mar 27, 2012 at 3:46 PM, Igor R <boost.lists@gmail.com> wrote:
> I thought its purpose was allow binding, but not evaluating, of a function object.

...when passed to bind() as a not first argument.

Ah, right, thx.
 

> 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.

Sure, protect doesn't do anything here.

> Is it possible to have bind generate a fully bound, nullary callable object?

bind(f, 1);

 Yeah, but that doesn't quite fit the bill! Ultimately I'm doing this for each member of a
range, via std algorithm, so I need to bind a unary argument to produce a nullary function
object, which I can then pass to an evaluation context, ie my g( ) function. If I've generated
the function object with bind and placeholder(s), it seems there's no way to prevent the binding
of the last placeholder from triggering evaluation, when what I require is an unevaluated nullary
function object.

Thx, Rob.