https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100091

--- Comment #4 from Pilar Latiesa <pilarlatiesa at gmail dot com> ---
> Of course such use of a lambda is quite pointless 

Not as pointless as it might appear. This defaulted template parameter enables
a form of stateful metaprogramming:

#include <type_traits>

template<typename, typename = decltype([]{})>
class T {};

static_assert(!std::is_same_v<T<int>, T<int>>); // passes with GCC 10

I don’t know if that is valid C++, and would love to know whether or not it is.

On the other hand, sometimes it is convenient to use lambdas this way:

template<typename TOp = decltype([](double x) { return x * x; })>
class my_functor
{
  [[no_unique_address]] TOp const Op = {};
};

Reply via email to