# Callable Entity

C++ is language of functions – global, instance or class functions. However it is not just functions that are callable. C++ provides an operator() to make even objects behave as if they were functions, affectionately known as functors, function objects to be more precise. With C++11 lambda’s have been added to callable entity’s list.

Overall here is the summary of the callable objects:

The last bit of code demos the newly added functionality in C++11, lambda. Lambda’s are un-named function objects that can maintain state (optional). They promote use of functional programming and the use of small un-named functions that we generally need with STL. Lets look at this lambda:

[] – indicates start of a lambda, un-named local function object (int val) - takes one parameter of type int by value {return val == tobefound;} - defines function body. Here the variable tobefound is captured by value, for this un-named function object and it returns bool.

Here is what compiler generates for lambda’s:

Here both lambda1 and lambda2 are equivalent. Thus lambda’s are syntactic sugar. Note this is one of the vary basic usage of lambda. This post is one of the basic post for upcoming ones on functional programming and lambdas.