[Solved] 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

[Solved] decltype in static_assert

static_assert works fine, is your code that never assert. The template struct X defines low and high as of type IntT. They are both the same type, whatever values they have. When you instantiate the struct (X<char,1,’a’> x) you are telling the compiler that the type of IntT is char and are giving to low … Read more