templated lambda, requires, __is_same and type traits (original) (raw)

Somehow __is_same doesnt like type traits evaluated inside of it when in function instantiation context:

using type = std::vector; using inner = int;

template concept range_value_int = std::same_as<std::ranges::range_value_t, int>;

template<class T, auto Cpt> concept generic_range_value = requires { Cpt.template operator()<std::ranges::range_value_t>(); };

template requires generic_range_value<T, []<std::same_as>() {}> void z() {}

template void y() {}

template<generic_range_value<[]<std::same_as>() {}> T> void x() {}

int main { static_assert( generic_range_value<type, []<std::same_as>() {}>, "fuck" );

y<type>();
x<type>();

}

This does not compile and fails at the instantiation of "x" on the templated lambda operator call. it interestingly doesn't fail when calling it inside the static assert or when its evaluated in a requires clause behind the function.

msvc compiles it just fine.

version stuff:

clang version 20.1.8
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\bin