Boost logo

Boost Users :

From: Olaf Krzikalla (krzikalla_at_[hidden])
Date: 2008-05-30 10:09:09


Hi,

is it possible to check a function bound to boost::function, if a
particular argument is actually needed?

Example:

----
struct bar {};
typedef boost::function<void(int, bar&)> tSlot;
void foo(tSlot& s);
void barNeeded(int, bar&);
void barNeeded(int);
void callfoo()
{
   foo(boost::bind(&barNeeded, _1, _2));
   foo(boost::bind(&barNotNeeded, _1));
}
void foo(tSlot& s)
{
   bar b;
   expensive_calculation(b);
   s(1, b);
}
----
How can I prevent expensive_calculation if the function barNotNeeded was 
  bound to tSlot?
Best regards
Olaf Krzikalla

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