diff --git a/uppsrc/Core/Defs.h b/uppsrc/Core/Defs.h index 0d858dadf..e0aac4fc9 100644 --- a/uppsrc/Core/Defs.h +++ b/uppsrc/Core/Defs.h @@ -216,6 +216,29 @@ template inline const T& max(const T& a, const T& b) { return a > b ? template 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 \ +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; diff --git a/uppsrc/Core/src.tpp/AppEnv$en-us.tpp b/uppsrc/Core/src.tpp/AppEnv$en-us.tpp index deab57279..02a2d8fe9 100644 --- a/uppsrc/Core/src.tpp/AppEnv$en-us.tpp +++ b/uppsrc/Core/src.tpp/AppEnv$en-us.tpp @@ -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; ] \ No newline at end of file +[s0; ]] \ No newline at end of file