
17 Aug
2015
17 Aug
'15
4:48 p.m.
I didn't know that. I was only targeting C++03/C++11.
This should work with C++11: template <typename T, typename F> void with(T &&t, F &&fn) { fn(std::forward<T>(t)); } with(make_foo(), [](foo &&f) { // do things with foo. }); // foo is destroyed. Don't think I can help w/r/t C++03 though, the lack of lambdas is a killer.