Browse Source

Ensure MIN/MAX overrides

Scott Lahteine 6 years ago
parent
commit
f4c625d3a1

+ 15
- 12
Marlin/src/core/minmax.h View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-#pragma once
24
-
25
 #undef MIN
23
 #undef MIN
26
 #undef MAX
24
 #undef MAX
27
 
25
 
28
 #ifdef __cplusplus
26
 #ifdef __cplusplus
29
 
27
 
30
-  extern "C++" {
28
+  #ifndef _MINMAX_H_
29
+  #define _MINMAX_H_
30
+
31
+    extern "C++" {
32
+
33
+      // C++11 solution that is standards compliant. Return type is deduced automatically
34
+      template <class L, class R> static inline constexpr auto MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
35
+        return lhs < rhs ? lhs : rhs;
36
+      }
37
+      template <class L, class R> static inline constexpr auto MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
38
+        return lhs > rhs ? lhs : rhs;
39
+      }
40
+      template<class T, class ... Ts> static inline constexpr const T MIN(T V, Ts... Vs) { return MIN(V, MIN(Vs...)); }
41
+      template<class T, class ... Ts> static inline constexpr const T MAX(T V, Ts... Vs) { return MAX(V, MAX(Vs...)); }
31
 
42
 
32
-    // C++11 solution that is standards compliant. Return type is deduced automatically
33
-    template <class L, class R> static inline constexpr auto MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
34
-      return lhs < rhs ? lhs : rhs;
35
-    }
36
-    template <class L, class R> static inline constexpr auto MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
37
-      return lhs > rhs ? lhs : rhs;
38
     }
43
     }
39
-    template<class T, class ... Ts> static inline constexpr const T MIN(T V, Ts... Vs) { return MIN(V, MIN(Vs...)); }
40
-    template<class T, class ... Ts> static inline constexpr const T MAX(T V, Ts... Vs) { return MAX(V, MAX(Vs...)); }
41
 
44
 
42
-  }
45
+  #endif
43
 
46
 
44
 #else
47
 #else
45
 
48
 

+ 1
- 0
Marlin/src/inc/MarlinConfig.h View File

43
 #include "../core/language.h"
43
 #include "../core/language.h"
44
 #include "../core/utility.h"
44
 #include "../core/utility.h"
45
 #include "../core/serial.h"
45
 #include "../core/serial.h"
46
+#include "../core/minmax.h"
46
 
47
 
47
 #endif // _MARLIN_CONFIG_H_
48
 #endif // _MARLIN_CONFIG_H_

+ 0
- 2
frameworks/CMSIS/LPC1768/include/lpc_types.h View File

145
 /* External data/function define */
145
 /* External data/function define */
146
 #define EXTERN extern
146
 #define EXTERN extern
147
 
147
 
148
-#include "../../../../src/core/minmax.h"
149
-
150
 /**
148
 /**
151
  * @}
149
  * @}
152
  */
150
  */

Loading…
Cancel
Save