[ Note: As specified in [dcl.fct], function declarations that have equivalent parameter declarations declare the same function and therefore cannot be overloaded:
Parameter declarations that differ only in the use of equivalent typedef “types” are equivalent. A typedef is not a separate type, but only a synonym for another type ([dcl.typedef]). [ Example:
typedef int Int; void f(int i); void f(Int i); void f(int i) { /* ... */ } void f(Int i) { /* ... */ }
— end example ]
Enumerations, on the other hand, are distinct types and can be used to distinguish overloaded function declarations. [ Example:
enum E { a }; void f(int i) { /* ... */ } void f(E i) { /* ... */ }
— end example ]
Parameter declarations that differ only in a pointer * versus an array [] are equivalent. That is, the array declaration is adjusted to become a pointer declaration ([dcl.fct]). Only the second and subsequent array dimensions are significant in parameter types ([dcl.array]). [ Example:
int f(char*); int f(char[]); int f(char[7]); int f(char[9]); int g(char(*)[10]); int g(char[5][10]); int g(char[7][10]); int g(char(*)[20]);
— end example ]
Parameter declarations that differ only in that one is a function type and the other is a pointer to the same function type are equivalent. That is, the function type is adjusted to become a pointer to function type ([dcl.fct]). [ Example:
void h(int()); void h(int (*)()); void h(int x()) { } void h(int (*x)()) { }
— end example ]
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); int f (int) { /* ... */ } int f (cInt) { /* ... */ }
— end example ]
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.”
Two parameter declarations that differ only in their default arguments are equivalent. [ Example: consider the following:
void f (int i, int j); void f (int i, int j = 99); void f (int i = 88, int j); void f (); void prog () { f (1, 2); f (1); f (); }
— end example ] — end note ]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4