Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "<?" and ">?" do in C++ [duplicate]

Tags:

c++

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.

like image 970
Cpt Pugsy Avatar asked May 12 '16 05:05

Cpt Pugsy


People also ask

What is duplicate elements in C?

In this program, we need to print the duplicate elements present in the array. This can be done through two loops. The first loop will select an element and the second loop will iteration through the array by comparing the selected element with other elements.

How do you check if a number is repeated in an array in C?

To count total duplicate elements in given array we need two loops. Run an outer loop loop from 0 to size . Loop structure must look like for(i=0; i<size; i++) . This loop is used to select each element of array and check next subsequent elements for duplicates elements using another nested loop.


1 Answers

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.

like image 111
Yu Hao Avatar answered Oct 15 '22 09:10

Yu Hao