Branch data Line data Source code
1 : : #pragma once
2 : : inline int min(int val)
3 : : {
4 : : return val;
5 : : }
6 : :
7 : : template<typename... Args> inline int min(int arg1, const Args&... args)//if this is functional programming, I don't want to know more about it.
8 : : {
9 : : int i=min(args...);
10 : : if (arg1<i) return arg1;
11 : : return i;
12 : : }
13 : :
14 : : inline int posmin(int val)
15 : : {
16 : : return val;
17 : : }
18 : :
19 : : template<typename... Args> inline int posmin(int arg1, const Args&... args)
20 : : {
21 : : int i=posmin(args...);
22 : : if (arg1>=0 && arg1<i) return arg1;
23 : : return i;
24 : : }
25 : :
26 : : template<int N> struct forceconst { enum { value = N }; };
27 : : #define forceconst(n) (forceconst<n>::value)
28 : :
29 : : //from nall, license: ISC
30 : : //round up to next highest single bit:
31 : : //round(15) == 16, round(16) == 16, round(17) == 32
32 : 691976 : inline unsigned bitround(unsigned x)
33 : : {
34 [ + + ]: 691976 : if ((x & (x - 1)) == 0) return x;
35 [ + + ]: 1668845 : while (x & (x - 1)) x &= x - 1;
36 : 575935 : return x << 1;
37 : : }
|