Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit18f5095

Browse files
committed
minimize diff; fix missing paren
1 parentbe460bc commit18f5095

File tree

1 file changed

+46
-50
lines changed

1 file changed

+46
-50
lines changed

‎api/Common.h

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -37,92 +37,63 @@ typedef enum {
3737
#defineSERIAL0x0
3838
#defineDISPLAY0x1
3939

40-
#ifdef __cplusplus
41-
}// extern "C"
42-
#endif
4340

4441
#ifdef __cplusplus
42+
}// extern "C"
4543

46-
template<classT,classL>
47-
automin(const T& a,const L& b) -> decltype(b < a ? b : a)
48-
{
49-
return (b < a) ? b : a;
50-
}
51-
52-
template<classT,classL>
53-
automax(const T& a,const L& b) -> decltype(b < a ? b : a)
54-
{
55-
return (a < b) ? b : a;
56-
}
57-
58-
59-
template<classT,classU,classV>
44+
template<classT,classU,classV>
6045
autoconstrain(const T& amt,const U& low,const V& high) -> decltype(amt < low ? low : (amt > high ? high : amt))
6146
{
6247
return amt < low ? low : (amt > high ? high : amt);
6348
}
64-
65-
template<classT>
49+
50+
template<classT>
6651
autoradians(const T& deg) -> decltype(deg * DEG_TO_RAD)
6752
{
6853
return deg * DEG_TO_RAD;
6954
}
7055

71-
template<classT>
56+
template<classT>
7257
autodegrees(const T& rad) -> decltype(rad * RAD_TO_DEG)
7358
{
7459
return rad * RAD_TO_DEG;
7560
}
7661

77-
template<classT>
62+
template<classT>
7863
autosq(const T& x) -> decltype(x*x)
7964
{
8065
return x*x;
8166
}
8267
#else
8368
#ifndef constrain
8469
#defineconstrain(amt,low,high) \
85-
({__typeof__ (amt) _amt = (amt); \
86-
__typeof__ (low) _low = (low); \
87-
__typeof__ (high) _high = (high); \
88-
_amt < _low ? _low : (_amt > _high ? _high :_amt); }
70+
({__typeof__ (amt) _amt = (amt); \
71+
__typeof__ (low) _low = (low); \
72+
__typeof__ (high) _high = (high); \
73+
_amt < _low ? _low : (_amt > _high ? _high :_amt); })
8974
#endif
90-
75+
9176
#ifndef radians
9277
#defineradians(deg) \
93-
({__typeof__ (deg) _deg = deg; \
94-
_deg * DEG_TO_RAD; })
78+
({__typeof__ (deg) _deg = deg; \
79+
_deg * DEG_TO_RAD; })
9580
#endif
96-
81+
9782
#ifndef degrees
9883
#definedegrees(rad) \
99-
({__typeof__ (rad) _rad = rad; \
100-
_rad * RAD_TO_DEG; })
84+
({__typeof__ (rad) _rad = rad; \
85+
_rad * RAD_TO_DEG; })
10186
#endif
102-
87+
10388
#ifndef sq
10489
#definesq(x) \
105-
({__typeof__ (x) _x = x; \
106-
_x * _x; })
107-
#endif
108-
109-
#ifndef min
110-
#definemin(a,b) \
111-
({__typeof__ (a) _a = (a); \
112-
__typeof__ (b) _b = (b); \
113-
_a < _b ? _a : _b; })
114-
#endif
115-
116-
#ifndef max
117-
#definemax(a,b) \
118-
({__typeof__ (a) _a = (a); \
119-
__typeof__ (b) _b = (b); \
120-
_a > _b ? _a : _b; })
90+
({__typeof__ (x) _x = x; \
91+
_x * _x; })
12192
#endif
12293
#endif
12394

12495
#ifdef __cplusplus
125-
extern"C"{
96+
extern"C"{
12697
#endif
12798

12899
typedefvoid (*voidFuncPtr)(void);
@@ -189,8 +160,32 @@ void loop(void);
189160

190161
#ifdef __cplusplus
191162
}// extern "C"
192-
#endif
193163

164+
template<classT,classL>
165+
automin(const T& a,const L& b) -> decltype((b < a) ? b : a)
166+
{
167+
return (b < a) ? b : a;
168+
}
169+
170+
template<classT,classL>
171+
automax(const T& a,const L& b) -> decltype((b < a) ? b : a)
172+
{
173+
return (a < b) ? b : a;
174+
}
175+
#else
176+
#ifndef min
177+
#definemin(a,b) \
178+
({__typeof__ (a) _a = (a); \
179+
__typeof__ (b) _b = (b); \
180+
_a < _b ? _a : _b; })
181+
#endif
182+
#ifndef max
183+
#definemax(a,b) \
184+
({__typeof__ (a) _a = (a); \
185+
__typeof__ (b) _b = (b); \
186+
_a > _b ? _a : _b; })
187+
#endif
188+
#endif
194189

195190
#ifdef __cplusplus
196191

@@ -213,3 +208,4 @@ void randomSeed(unsigned long);
213208
longmap(long,long,long,long,long);
214209

215210
#endif// __cplusplus
211+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp