Please look at the following C++0x lambda related code:
typedef uint64_t (*WEIGHT_FUNC)(void* param);
typedef std::map<std::string, WEIGHT_FUNC> CallbackTable;
CallbackTable table;
table["rand_weight"] = [](void* param) -> uint64_t
{
return (rand() % 100 + 1);
};
I got an error (in Visual Studio 2010) that the lambda couldn't be converted to the type of WEIGHT_FUNC
. I also know the answer: using std::function object
:
typedef std::function<uint64_t (void*)> WEIGHT_FUNC;
However, I also want to know how I can receive the type of lambda WITHOUT using std::function
. What type should it be?