the question is about overload functions. Take a look at this code:
#include<iostream> void fv(int){} void fc(const int){} void fvr(int&){} void fcr(const int&){} void fm(void(*fun)(const int)) { std::cout << "Constant called" << std::endl; } //void fm(void(*fun)(int)) //{ // std::cout << "non Constant called" << std::endl; //} void fm(void(*fun)(const int&)) { std::cout << "Constant ref called" << std::endl; } void fm(void(*fun)(int&)) { std::cout << "non Constant ref called" << std::endl; } int main() { fm(&fc); fm(&fv); fm(&fvr); fm(&fcr); return 0; }
If you uncomment the function void fm(void(*fun)(int)) , you will find that the compiler cannot statically overload the function with a pointer to a function that takes a parameter by value and a pointer to a function that takes a value const. In addition, if you uncomment void(*fun)(const int) and the comment void(*fun)(const int) , then everything compiles successfully. But, if we use links, it compiles OK. Do not understand why, could you please explain to me? Does this mean that function pointers that take a parameter by value and the value of const are the same?
UPD: The top-level constant does not affect the signature of the function. There is a good explanation of why const-const should be removed.
source share