When passing a deduced type as r-value reference I get universal reference functionality and can archieve perfect forwarding like this:
template <typename T>
void func(T&& t) {
other_func(std::forward<T>(t));
}
...due to the way T is derived and the standard's reference collapse rules.
Now consider other_func takes a function object
template <typename T>
void func(T&& t) {
other_func([](int v) { return t + v; }); // I chose addition for example purposes
}
Now obviously this won't compile due to t not being captured. My question is: How do I capture it so the captured value will be whatever T is deduced to?
Is this possible using the new generic lambda captures? And if... how?
[t = std::forward<T>(t)] ?
I still don't really get the mechanics of the new capture initializers...