Using and Porting GNU CC
It is very convenient to have operators which return the ``minimum'' or the ``maximum'' of two arguments. In GNU C++ (but not in GNU C),
a <? b
a >? b
These operations are not primitive in ordinary C++, since you can use a macro to return the minimum of two things in C++, as in the following example.
#define MIN(X,Y) ((X) < (Y) ? : (X) : (Y))
You might then use `
int min = MIN (i, j);' to set min to
the minimum value of variables i and j.
However, side effects in
Y may cause unintended
behavior. For example,
MIN (i++, j++) will fail, incrementing
the smaller counter twice. A GNU C extension allows you to write safe
macros that avoid this kind of problem (see Naming Types). However, writing
macros also forces you to use function-call notation notation for a
fundamental arithmetic operation. Using GNU C++ extensions, you can
int min = i <? j;' instead.
>? are built into the compiler, they properly
handle expressions with side-effects; `
int min = i++ <? j++;'