What does T&& (double ampersand) mean in C++11?

It declares an rvalue reference (standards proposal doc). Here’s an introduction to rvalue references. Here’s a fantastic in-depth look at rvalue references by one of Microsoft’s standard library developers. CAUTION: the linked article on MSDN (“Rvalue References: C++0x Features in VC10, Part 2”) is a very clear introduction to Rvalue references, but makes statements about … Read more

Perfect forwaring of auto&& in generic lambda

In C++20 and later auto lambda20 = []<class F, class…Ts>(F &&fn, Ts &&…args) { return std::forward<F>(fn)(std::forward<Ts>(args)…); }; In C++pre20 : C++11,14,17 auto lambda14 = [](auto &&fn, auto &&…args) { return std::forward< std::conditional_t< std::is_rvalue_reference_v<decltype(fn)>, typename std::remove_reference_t<decltype(fn)>, decltype(fn)> >(fn)( std::forward< std::conditional_t<std::is_rvalue_reference<decltype(args)>::value, typename std::remove_reference<decltype(args)>::type, decltype(args) >>(args)…); }; Example #include <iostream> using namespace std; int main() { auto lambda20 … Read more