Library of Assembled Shared Sources
Bind

Detailed Description

bind call and arguments to a nullary callback.

#include <lass/util/bind.h>
namespace using lass::util;
void fun(const std::string& a);
float moreFun(float a, float b);
class Spam
{
void ham(const std::string& something);
std::string eggs(int num) const;
};
// ...
// regulare function call
Callback0 boundFun = bind(fun, "hello world!");
// with return value. type conversion is allowed both on arguments and result
CallbackR1<double> boundMoreFun(moreFun, 5, 6);
// bound method call, you have to make sure spam1 is still alive when call is executed!
Spam spam1;
Callback0 boundHam = bind(&Spam::ham, &spam1, "eggs");
// bound method call with smart pointer, return value is ignored
SharedPtr<Spam> spam2(new Spam);
Callback0 boundEggs = bind(&Spam::eggs, spam2, 3);
// ...
boundFun();
double result = boundMoreFun();
boundHam();
boundEggs();
Library for Assembled Shared Sources.
Definition config.h:53