File tree 1 file changed +27
-14
lines changed
1 file changed +27
-14
lines changed Original file line number Diff line number Diff line change @@ -37,20 +37,6 @@ typedef enum {
37
37
#define SERIAL 0x0
38
38
#define DISPLAY 0x1
39
39
40
- #ifndef min
41
- #define min (a ,b ) \
42
- ({ __typeof__ (a) _a = (a); \
43
- __typeof__ (b) _b = (b); \
44
- _a < _b ? _a : _b; })
45
- #endif
46
-
47
- #ifndef max
48
- #define max (a ,b ) \
49
- ({ __typeof__ (a) _a = (a); \
50
- __typeof__ (b) _b = (b); \
51
- _a > _b ? _a : _b; })
52
- #endif
53
-
54
40
#ifndef constrain
55
41
#define constrain (amt,low,high ) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
56
42
#endif
@@ -130,6 +116,33 @@ void loop(void);
130
116
} // extern "C"
131
117
#endif
132
118
119
+ #ifdef __cplusplus
120
+ template <class T , class L >
121
+ auto min (const T& a, const L& b) -> decltype((b < a) ? b : a)
122
+ {
123
+ return (b < a) ? b : a;
124
+ }
125
+
126
+ template <class T , class L >
127
+ auto max (const T& a, const L& b) -> decltype((b < a) ? b : a)
128
+ {
129
+ return (a < b) ? b : a;
130
+ }
131
+ #else
132
+ #ifndef min
133
+ #define min (a,b ) \
134
+ ({ __typeof__ (a) _a = (a); \
135
+ __typeof__ (b) _b = (b); \
136
+ _a < _b ? _a : _b; })
137
+ #endif
138
+ #ifndef max
139
+ #define max (a,b ) \
140
+ ({ __typeof__ (a) _a = (a); \
141
+ __typeof__ (b) _b = (b); \
142
+ _a > _b ? _a : _b; })
143
+ #endif
144
+ #endif
145
+
133
146
#ifdef __cplusplus
134
147
135
148
/* C++ prototypes */
You can’t perform that action at this time.
0 commit comments