Ensure MIN/MAX overrides
This commit is contained in:
parent
3019713402
commit
f4c625d3a1
@ -20,26 +20,29 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#undef MIN
|
#undef MIN
|
||||||
#undef MAX
|
#undef MAX
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
extern "C++" {
|
#ifndef _MINMAX_H_
|
||||||
|
#define _MINMAX_H_
|
||||||
|
|
||||||
// C++11 solution that is standards compliant. Return type is deduced automatically
|
extern "C++" {
|
||||||
template <class L, class R> static inline constexpr auto MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
|
|
||||||
return lhs < rhs ? lhs : rhs;
|
|
||||||
}
|
|
||||||
template <class L, class R> static inline constexpr auto MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
|
|
||||||
return lhs > rhs ? lhs : rhs;
|
|
||||||
}
|
|
||||||
template<class T, class ... Ts> static inline constexpr const T MIN(T V, Ts... Vs) { return MIN(V, MIN(Vs...)); }
|
|
||||||
template<class T, class ... Ts> static inline constexpr const T MAX(T V, Ts... Vs) { return MAX(V, MAX(Vs...)); }
|
|
||||||
|
|
||||||
}
|
// C++11 solution that is standards compliant. Return type is deduced automatically
|
||||||
|
template <class L, class R> static inline constexpr auto MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
|
||||||
|
return lhs < rhs ? lhs : rhs;
|
||||||
|
}
|
||||||
|
template <class L, class R> static inline constexpr auto MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
|
||||||
|
return lhs > rhs ? lhs : rhs;
|
||||||
|
}
|
||||||
|
template<class T, class ... Ts> static inline constexpr const T MIN(T V, Ts... Vs) { return MIN(V, MIN(Vs...)); }
|
||||||
|
template<class T, class ... Ts> static inline constexpr const T MAX(T V, Ts... Vs) { return MAX(V, MAX(Vs...)); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -43,5 +43,6 @@
|
|||||||
#include "../core/language.h"
|
#include "../core/language.h"
|
||||||
#include "../core/utility.h"
|
#include "../core/utility.h"
|
||||||
#include "../core/serial.h"
|
#include "../core/serial.h"
|
||||||
|
#include "../core/minmax.h"
|
||||||
|
|
||||||
#endif // _MARLIN_CONFIG_H_
|
#endif // _MARLIN_CONFIG_H_
|
||||||
|
@ -145,8 +145,6 @@ typedef int32_t(*PFI)();
|
|||||||
/* External data/function define */
|
/* External data/function define */
|
||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
|
|
||||||
#include "../../../../src/core/minmax.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user