[x = std::forward<decltype(x)>] behave like you expect?
by Vittorio Romeo
From the article:
Perfect forwarding and forwarding references allow developers to write generic template functions that retain the lvalueness/rvalueness of passed arguments [...] Let's try to use auto&&, std::forward and C++14's generalized lambda capture syntax to implement our desired semantics. [...] What we really want to do is:
- Capture by copy if a is an rvalue reference.
- Capture by reference if a is an lvalue reference.