Built-in operator candidates

C ++ 03 $ 13.6 / 1- "[...] If there is a user candidate with the same name and parameter types as the built-in operator-operator-candidate, the built-in function of the operator is hidden and is not included in the set of candidate functions."

I am not sure about the intent of this quotation from the Standard. Is it possible to define a user-defined candidate function with the same name and type as the built-in operator?

eg. below, which is clearly wrong.

int operator+(int) 

So what does this quote mean?

+7
c ++ overload-resolution built-in candidate
source share
1 answer

Just select one of them in 13.6. how

For each pointer or enumeration type T, there are possible operator functions of the form

 bool operator<(T, T); bool operator>(T, T); bool operator<=(T, T); bool operator>=(T, T); bool operator==(T, T); bool operator!=(T, T); 

So,

 enum Kind { Evil, Good }; bool operator<(Kind a, Kind b) { ... } 
+1
source share

All Articles