Consider this concept, which has a default template parameter.
template<class T, class = decltype([]{})>
concept IsDefined = sizeof(T) > 0;
Since every lambda has a distinct type, one might expect every instantiation of IsDefined<X>
to be distinct.
struct SomeType;
static_assert( false == IsDefined<SomeType> );
struct SomeType
{
// Defined.
};
static_assert( true == IsDefined<SomeType> );
Clang and MSVC agree and compile this code. GCC fails the second static assert, but only if the first static assert is evaluated.
error: static assertion failed
17 | static_assert( true == IsDefined<SomeType> );
Are any of these compilers wrong? Or is this behavior unspecified?
class = decltype([]{})
is not a default functional argument. Why do you expect it to be distinct at concept instantiations? It may be not specified by the standard. – Gaven