|
Boost Users : |
Subject: Re: [Boost-users] [Bind] Understanding protect
From: Igor R (boost.lists_at_[hidden])
Date: 2012-03-27 10:46:00
> I thought its purpose was allow binding, but not evaluating, of a function object.
...when passed to bind() as a not first argument.
> 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);
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