8

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

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

e.g. the below which is clearly wrong.

int operator+(int)

So what does this quote mean?

Chubsdad
  • 24,777
  • 4
  • 73
  • 129
  • 1
    Doesn't answer the question, but related: ["Can I define an operator overload that works with built-in / intrinsic / primitive types?"](http://www.parashift.com/c++-faq-lite/intrinsic-types.html#faq-26.10) – Mark Rushakoff Nov 09 '10 at 04:06
  • I think a better example might be "int operator+(int,int);" – Giffyguy Nov 09 '10 at 06:58

1 Answers1

1

Just pick one of those in 13.6. Like

For every pointer or enumeration type T, there exist candidate 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) { ... }
Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212