Considering this well-known C++ pattern :
template <class... Ts> struct overload : Ts... { using Ts::operator()...; };
template <class... Ts> overload(Ts...) -> overload<Ts...>; // clang needs this deduction guide,
// even in C++20 for some reasons ...
I wonder why declaring one of the parameter as a mutable lambda changes the override resolution.
Live example here on godbolt :
#include <iostream>
template <class... Ts> struct overload : Ts... { using Ts::operator()...; };
template <class... Ts> overload(Ts...) -> overload<Ts...>; // clang needs this deduction guide,
// even in C++20 for some reasons ...
auto main() -> int
{
auto functor_1 = overload{
[](int &&){
std::cout << "int\n";
},
[](auto &&) { // making this lambda `mutable` makes deduction mismatch ?
std::cout << "smthg else\n";
}
};
functor_1(42); // prints `int`
auto functor_2 = overload{
[](int &&){
std::cout << "int\n";
},
[](auto &&) mutable {
std::cout << "smthg else\n";
}
};
functor_2(42); // prints `smth else`
}