defs: use C++ min/max when compiling in C++ mode

This commit is contained in:
Lephe 2023-01-01 18:49:13 +01:00
parent 1272a6a71a
commit d3b29c50e6
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 6 additions and 0 deletions

View File

@ -14,6 +14,11 @@
#define GAUTOTYPE __auto_type
#endif
#ifdef __cplusplus
#include <algorithm>
using std::min;
using std::max;
#else
/* min(), max() (without double evaluation) */
#define min(a, b) ({ \
GAUTOTYPE _a = (a); \
@ -25,6 +30,7 @@
GAUTOTYPE _b = (b); \
_a > _b ? _a : _b; \
})
#endif
/* sgn() (without double evaluation) */
#define sgn(s) ({ \