Reputation: 385274
I'm stuck on GCC 4.4, so despite introducing -std=c++0x
to my codebase have no use of lambdas.
Is there a C++03 equivalent to an empty lambda [](){}
, that I could use safely as a default argument for a generic argument with some type Callback
?
I ask because the old std::plus
, std::less
etc were handy but I can't seem to find a no-op, void
-returning equivalent.
Upvotes: 0
Views: 1653
Reputation: 275740
struct noop {
static void do_nothing(){};
void operator()()const{};
typedef void(*pf)();
operator pf()const { return do_nothing; }
};
noop()
is pretty equivalent to [](){}
.
It even converts to function pointer like the noop lambda does.
Upvotes: 6