Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define C_MAX_2(a, b) (((a) > (b)) ? (a) : (b))
- #define C_MAX_3(a, b, c) C_MAX_2((C_MAX_2((a),(b))), (c))
- #define C_MAX_4(a, b, c, d) C_MAX_2((C_MAX_2((a),(b))),
- (C_MAX_2((c),(d))))
- #define C_MAX_5(a, b, c, d, e) C_MAX_2((C_MAX_3((a),(b), (c))),
- (C_MAX_2((d),(e))))
- #define MAX_2(n1, n2) (n1 > n2 ? n1 : n2)
- #define MAX_3(n1, n2, n3) MAX_2(n1, MAX_2(n2, n3))
- #define MAX_4(n1, n2, n3, n4) MAX_2(n1, MAX_3(n2, n3, n4))
- #define MAX_5(n1, n2, n3, n4, n5) MAX_2(n1, MAX_4(n2, n3, n4, n5))
- #define COUNTARGS(...) GET21ST(__VA_ARGS__,COUNTDOWN())
- #define COUNTDOWN() 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
- #define GET21ST(a20,a19,a18,a17,a16,a15,a14,a13,a12,a11,a10,a9,a8,a7,a6,a5,a4,a3,a2,a1,a,...) a
- #define EVAL(...) EVAL1(EVAL1(EVAL1(__VA_ARGS__)))
- #define EVAL1(...) EVAL2(EVAL2(EVAL2(__VA_ARGS__)))
- #define EVAL2(...) EVAL3(EVAL3(EVAL3(__VA_ARGS__)))
- #define EVAL3(...) EVAL4(EVAL4(EVAL4(__VA_ARGS__)))
- #define EVAL4(...) EVAL5(EVAL5(EVAL5(__VA_ARGS__)))
- #define EVAL5(...) __VA_ARGS__
- #define VANISH()
- #define OBSTRUCT(...) __VA_ARGS__ VANISH()
- #define COUNTDOWN() 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
- #define COUNTARGS(...) EVAL(OBSTRUCT(GET21ST)(__VA_ARGS__,COUNTDOWN()))
- #define GET21ST(a20,a19,a18,a17,a16,a15,a14,a13,a12,a11,a10,a9,a8,a7,a6,a5,a4,a3,a2,a1,a,...) a
- #define MAX_1(n) n
- #define MAX_2(a,b) ((a)>(b)?(a):(b))
- #define MAX_3(a,...) MAX_2(a,MAX_2(__VA_ARGS__))
- #define MAX_4(a,...) MAX_2(a,MAX_3(__VA_ARGS__))
- ...
- #define MAX_20(a,...) MAX_2(a,MAX_19(__VA_ARGS__))
- #define CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__)
- #define PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
- #define MAX(...) CAT(MAX_,COUNTARGS(__VA_ARGS__))(__VA_ARGS__)
- MAX(2,3,4,1)
- (2>(3>(4>1?4:1)?3:(4>1?4:1))?2:(3>(4>1?4:1)?3:(4>1?4:1)))
- #include <vector>
- #include <algorithm>
- #define MAX(...) [](auto v)constexpr{
- return *std::max_element(v.begin(),
- v.end());
- }(std::vector<float>{__VA_ARGS__})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement