vendredi 27 février 2015

How to automatically convert a lambda to a std::function?

In C++11+ one can write something like this:



#include <functional>

std::function<float(int)> f = [](int i){ return i / 100.0; };


Is there a way to write a function make_std_function (possibly using templates) which allows to create a std::function object in the following manner:



auto f = make_std_function([](int i){ return i / 100.0; });

Aucun commentaire:

Enregistrer un commentaire