I'd like to make the return value type generic using std::function, but it does not work, code: debuggable code can be found: http://cpp.sh/5bk5
class Test { public: template < typename R, typename F = std::function<R()> > R f(F&& op) { op(); }; void t() { int a = 10; f([this, a]() { return "chars"; }); }; }; int main() { t::Test test; test.t(); return 0; }
Aucun commentaire:
Enregistrer un commentaire