On 2021-03-24 14:46, Edward Diener via Boost wrote:
Why are consts ignored in function parameters ? Is not void f(int const) different from void f(int) ? In one the argument passed can not be changed and in the other it can. How can they be the same ?
The standard states in [dcl.fct]/5 that "After producing the list of parameter types, any top-level cv-qualifiers modifying a parameter type are deleted when forming the function type."
Then the parameter is not const and you have a mismatch. Can't you use different parameter types and use SFINAE by comparing the two after removing const?
Thanks ! Maybe I can. But to have to do so in such a simple situation seems very strange.
You can use C++20 std::type_identity (or roll your own) to prevent the
second T from being deduced. In Richard Smith's example:
template