Thanks for your help, that got me over my hurdle!

-----Original Message-----
From: Wilka [mailto:wilka@blueyonder.co.uk]
Sent: Monday, October 15, 2001 1:57 PM
To: boost@yahoogroups.com
Subject: RE: [boost] Function and Bind


When you're passing a functor (such as boost::function) to a boost::function, you need to explicitly tell it what the return value is. So in your case, if you change:

<code>
//BEGIN PROBLEM
OneArgFunction          f_oneArg;

f_oneArg = boost::bind(f2, ulValue, _1);
//END PROBLEM
return(DoIt_One(f_oneArg));
</code>

To

<code>
//BEGIN PROBLEM
OneArgFunction          f_oneArg;

f_oneArg = boost::bind<bool>(f2, ulValue, _1); // Note the "<bool>" //END PROBLEM return(DoIt_One(f_oneArg)); </code>

It should work fine.

- Wilka

> -----Original Message-----
> From: brownell@aegisgrp.com [mailto:brownell@aegisgrp.com]
> Sent: 15 October 2001 21:15
> To: boost@yahoogroups.com
> Subject: [boost] Function and Bind
>
>
> I have a question that is probably better asked in code than in
> words, but I will try the words route first, and if that doesn't
> work, I have pasted code that may explain the situation better.
>
> I have one function that takes 1 arg (call it Func1), another that
> takes 2 args (call it Func2).  Both these functions take
> boost::functionX params.  Somehow, I need to bind a value to the
> first arg in Func2, and pass that new function to Func1. 
>
> I can not wait for the return value of Func1, as these function are
> used to update algorithm progress.
>
> Make any sense?  Hopefully the code will.
>
> Thanks for any and all help,
> Dave Brownell
>
> #include<iostream>
>
> #include "boost\bind.hpp"
> #include "boost\Function.hpp"
>
> typedef boost::function1<bool, unsigned long>                      
> OneArgFunction;
> typedef boost::function2<bool, unsigned long, unsigned long>       
> TwoArgFunction;
>
> inline bool WriteOne(unsigned long ul1)
> {
>     std::cout << ul1 << std::endl;
>     return(true);
> }
>
> inline bool WriteTwo(unsigned long ul1, unsigned long ul2)
> {
>     std::cout << "(" << ul2 << ") " << ul1 << std::endl;
>     return(true);
> }
>
> bool DoIt_One(OneArgFunction &f)
> {
>     if(f.empty() == false)
>         f(1);
>
>     return(true);
> }
>
> bool DoIt_Two(TwoArgFunction &f2, unsigned long ulValue)
> {
>     if(f.empty() == false)
>         return(false);
>
>     //BEGIN PROBLEM
>     OneArgFunction          f_oneArg;
>
>     f_oneArg = boost::bind(f2, ulValue, _1);
>     //END PROBLEM
>     return(DoIt_One(f_oneArg));
> }
>
> int main(void)
> {
>     TwoArgFunction          f2 = &WriteTwo;
>
>     DoIt_Two(f2, 2);
>
>     return(true);
> }
>
>
> Info: http://www.boost.org  Unsubscribe:
> <mailto:boost-unsubscribe@yahoogroups.com>
>
> Your use of
> Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>



Info: http://www.boost.org  Unsubscribe: <mailto:boost-unsubscribe@yahoogroups.com>

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/