As far as the C++ language is concerned, these two declarations are precisely equivalent:
void foo(const int);
void foo(int);
Quoth the C++11 (latest public draft) standard, section 13.1 "Overloadable declarations":
Parameter declarations that differ only in the presence or absence of const
and/or volatile
are equivalent. That is, the const
and volatile
type-specifiers for each parameter type are ignored when determining which function is being declared, defined, or called. Example:
typedef const int cInt;
int f (int);
int f (const int); // redeclaration of f(int)
int f (int) { /* ... */ } // definition of f(int)
int f (cInt) { /* ... */ } // error: redefinition of f(int)
Only the const
and volatile
type-specifiers at the outermost level of the parameter type specification are ignored in this fashion; const
and volatile
type-specifiers buried within a parameter type specification are significant and can be used to distinguish overloaded function declarations.124 In particular, for any type T
, “pointer to T
,” “pointer to const T
,” and “pointer to volatile T
” are considered distinct parameter types, as are “reference to T
,” “reference to const T
,” and “reference to volatile T
.”
124 When a parameter type includes a function type, such as in the case of a parameter type that is a pointer to function, the const
and volatile
type-specifiers at the outermost level of the parameter type specifications for the inner function type are also ignored.
So, the reason why function declarations are allowed to have const
parameters is because the standard says they are equivalent to function declarations that have non-const
parameters.
It should go without saying that the implication is you can't overload a function based on the cv-qualification of its parameters.
A const
type specifier only matters in the function's definition, where it prevents the local modification of that parameter.
I suppose no one could think of a good reason to introduce the additional complexity that would be required to forbid const
(and volatile
) in declarations, when they are allowed and significant in definitions.