auto lambda = [](){ return 7; };
std::result_of<decltype(lambda)()>::type val = lambda(); // 'val' : illegal use of type 'void'
I get the error: 'val' : illegal use of type 'void'. Why would the type resolve as void?
I may be mistaken about what result_of gets me. I just want the return value from anything I can pass a std::function.
If your compiler fails to compile that, then don’t use
std::result_of:That is exactly the same, and it should(well, could) work in VC2010.
You could also use
auto, though I don’t think this is what you want:Edit: Since you’re using this in the return value of a function, then the
decltypesolution shown above works fine:Demo here.