vendredi 29 juillet 2016

Wrapping a templated function call in a lambda

I am trying to write code to do something similar (code written for demonstration purposes) to this:

template <typename F, typename Args...>
inline auto runFunc(F func) -> foo
{
    return foo([func](Args... args) -> std::result_of<F>::type
        {
            // Do something before calling func
            func(args...);
            // Do something after call func
        });
}

So basically I am trying to write a function that returns an object that takes lambda that matches the templated function type. Obviously this code won't work because I do not have Args... defined. How would I solve this in C++11?

Aucun commentaire:

Enregistrer un commentaire