I recently had problem with code like this:
constexpr auto lambda = []{};
template<auto& l>
struct Lambda {};
template<auto& l>
void test(Lambda<l>) {}
int main() {
test(Lambda<lambda>{});
}
Both clang and GCC tells that it can't deduce l
.
However, if I add const there:
// ----v
template<const auto& l>
void test(Lambda<l>) {}
Then everything works with clang. GCC still fails. What's happening here? Can it not deduce the const
itself? Is this a GCC bug for it to not deducing l
in both cases?