[Bind?] Returning generators instead of evaluating.

Hi All Does this functionality exist anywhere in Boost? If so can someone point me to it, and if not does it seem like a useful thing? Thx, - Rob. using boost::function; using boost::bind; template <typename T, typename T1> function<T( )> function<T( )> make_generator( function<T(T1)> f, T1 t1 ) { return bind( f, t1 ); } template <typename T, typename T1, typename T2> function<T( )> function<T( )> make_generator( function<T(T1, T2)> f, T1 t1, T2 t2 ) { return bind( f, t1, t2 ); } template <typename T, typename T1, typename T2, typename T3> function<T( )> function<T( )> make_generator( function<T(T1, T2, T3)> f, T1 t1, T2 t2, T3 t3 ) { return bind( f, t1, t2, t3 ); } // ...etc...

Robert Jones-2 wrote:
How is make_generator different from bind? Why function<T()> g = bind(f,v); Doesn't works for you? Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/Bind-Returning-generators-instead-of-eval... Sent from the Boost - Users mailing list archive at Nabble.com.

On Tue, Oct 18, 2011 at 3:54 PM, Vicente Botet <vicente.botet@wanadoo.fr>wrote:
Hi Vicente Thanks for answering. My initial response was "Doh, I've asked a really stupid question here.", which may still be true! But walk a little with me on this... In this code sequence #include <vector> #include <iostream> #include "boost/assign/std/vector.hpp" #include "boost/function.hpp" #include "boost/bind.hpp" using boost::function; using boost::bind; void do_it( function<void()> f ) { f( ); } void print( int i ) { std::cout << i << std::endl; } template <typename T, typename T1> function<T( )> make_generator( function<T(T1)> f, T1 t1 ) { return bind( f, t1 ); } template <typename T, typename T1, typename T2> function<T( )> make_generator( function<T(T1, T2)> f, T1 t1, T2 t2 ) { return bind( f, t1, t2 ); } template <typename T, typename T1, typename T2, typename T3> function<T( )> make_generator( function<T(T1, T2, T3)> f, T1 t1, T2 t2, T3 t3 ) { return bind( f, t1, t2, t3 ); } // ...etc... int main( ) { using namespace boost::assign; std::vector<int> v; v += 1,2,3,4,5,6,7; for_each( v.begin(), v.end(), bind( do_it, bind( make_generator<void, int>, print, _1 ) )); } ...how would you write the final for_each using bind directly, given that the other interfaces are fixed? I think you'd need to specify the exact types taken and returned by bind, which are less than convenient to work with. So I think the answer to 'doesn't bind work for me?', is no, because I'd like specify the template instantiation types in a more convenient way. That may all be a load of gibberish - I'm feeling my way a bit here! Also, if my function signature handling skills were better, it might be better to specify the template parameter(s) of make_generator as a function signature or MPL type list. Thx, Rob.

On Thu, Oct 20, 2011 at 8:50 PM, Mathias Gaunard < mathias.gaunard@ens-lyon.org> wrote:
Could you demonstrate? Ideally using the standard one, as I don't have Phoenix V3 available in this context. Thx, Rob.
participants (3)
-
Mathias Gaunard
-
Robert Jones
-
Vicente Botet