5

I was browsing through some code written by another programmers code, to try and learn from it. I eventually ran into this code:

inline const FLOAT minx() const { return p1.x <? p2.x; }
inline const FLOAT maxx() const { return p1.x >? p2.x; }

This code didn't compile, and I was able to make it work by changing the code to this:

inline const FLOAT minx() const { return p1.x < p2.x ? p1.x : p2.x; }
inline const FLOAT minx() const { return p1.x > p2.x ? p1.x : p2.x; }

By doing so I can already assume what the code is supposed to do. But searching around I haven't found any other examples that implement it this way. Was this just bad code, that doesn't even compile, or does this actually work on certain compilers (and how?).

Thank you.

Cpt Pugsy
  • 61
  • 3

1 Answers1

6

They are not part of standard C++, but GCC extensions.

From Deprecated Features:

The G++ minimum and maximum operators (<? and >?) and their compound forms (<?=) and >?=) have been deprecated and are now removed from G++. Code using these operators should be modified to use std::min and std::max instead.

Note that they are, as the title says, deprecated.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294