Boost logo

Boost :

From: brownell_at_[hidden]
Date: 2001-10-15 15:15:27

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 "boost\bind.hpp"
#include "boost\Function.hpp"

typedef boost::function1<bool, unsigned long>
typedef boost::function2<bool, unsigned long, unsigned long>

inline bool WriteOne(unsigned long ul1)
    std::cout << ul1 << std::endl;

inline bool WriteTwo(unsigned long ul1, unsigned long ul2)
    std::cout << "(" << ul2 << ") " << ul1 << std::endl;

bool DoIt_One(OneArgFunction &f)
    if(f.empty() == false)


bool DoIt_Two(TwoArgFunction &f2, unsigned long ulValue)
    if(f.empty() == false)

    OneArgFunction f_oneArg;

    f_oneArg = boost::bind(f2, ulValue, _1);

int main(void)
    TwoArgFunction f2 = &WriteTwo;

    DoIt_Two(f2, 2);


Boost list run by bdawes at, gregod at, cpdaniel at, john at