mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: findarg
git-svn-id: svn://ultimatepp.org/upp/trunk@5496 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a792a010b1
commit
a5a367feb7
2 changed files with 32 additions and 1 deletions
|
|
@ -216,6 +216,29 @@ template <class T> inline const T& max(const T& a, const T& b) { return a > b ?
|
|||
template <class T>
|
||||
inline T minmax(T x, T _min, T _max) { return min(max(x, _min), _max); }
|
||||
|
||||
//$-int findarg(const T& x, const T1& p0, ...);
|
||||
inline void findarg_NOP() {} // Only to make List work for findarg
|
||||
|
||||
#define E__TL(I) typename COMBINE(T, I)
|
||||
#define E__NFIf(I) findarg_NOP(); if(x == COMBINE(p, I)) return I - 1; findarg_NOP()
|
||||
#define E__NFValue(I) const COMBINE(T, I)& COMBINE(p, I)
|
||||
|
||||
#define E__NFBody(I) \
|
||||
template <typename T, __List##I(E__TL)> \
|
||||
int findarg(const T& x, __List##I(E__NFValue)) \
|
||||
{ \
|
||||
__List##I(E__NFIf); \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
__Expand40(E__NFBody)
|
||||
|
||||
#undef E__TL
|
||||
#undef E__NFIf
|
||||
#undef E__NFValue
|
||||
|
||||
//$+
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef signed char int8;
|
||||
typedef unsigned char uint8;
|
||||
|
|
|
|||
|
|
@ -149,6 +149,14 @@ URL that will be opened in the browser&]
|
|||
[s0;l288; [%% If ][*@3 x][%% is higher than ][*@3 `_max][%% it returns ][*@3 `_max.]&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:findarg`(const T`&`,const T1`&`,`.`.`.`): [@(0.0.255) template]_<[@(0.0.255) class]_
|
||||
[*@4 T]>_[@(0.0.255) int]_[* findarg]([@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x],
|
||||
[@(0.0.255) const]_[*@4 T1][@(0.0.255) `&]_[*@3 p0], ...)&]
|
||||
[s2;%% Searches the list of arguments for the value of [%-*@3 x]. If
|
||||
it is found, function returns the index of argument (starting
|
||||
with 0). If not found, `-1 is returned.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:CpuSSE`(`): [@(0.0.255) bool]_[* CpuSSE]()&]
|
||||
[s2;%% Returns true if CPU has SSE support.&]
|
||||
[s3; &]
|
||||
|
|
@ -164,4 +172,4 @@ URL that will be opened in the browser&]
|
|||
[s5;:CPU`_Cores`(`): [@(0.0.255) int]_[* CPU`_Cores]()&]
|
||||
[s2;%% Returns the number of cores the CPU has.&]
|
||||
[s3; &]
|
||||
[s0; ]
|
||||
[s0; ]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue