This is similar to (but different from) this question.
Here is some simple test code to illustrate some weirdness I have discovered with Sun CC:
//--
This looks like a compiler problem in CC
. The C++ standard says (in 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.
But there are const
/volatile
modifiers that can participate in overloading, as the standard mentions shortly afterwards:
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.