Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

EXPERT MACRO PROGRAMMING

Name: Anonymous 2014-03-09 5:07

#define UP_DETAIL_PP_CAT_II(x, y) x##y
#define UP_DETAIL_PP_CAT_I(x, y) UP_DETAIL_PP_CAT_II(x, y)
#define UP_PP_CAT(x, y) UP_DETAIL_PP_CAT_I(x, y)

#define UP_PP_EMPTY()
#define UP_PP_COMMA() ,
#define UP_PP_FIRST(x, ...) x
#define UP_PP_REST(x, ...) __VA_ARGS__
#define UP_PP_EAT(...)
#define UP_PP_EXPAND(...) __VA_ARGS__
#define UP_PP_IDENTITY(...) __VA_ARGS__ UP_PP_EMPTY
#define UP_PP_DEFER(...) __VA_ARGS__ UP_PP_EMPTY()
#define UP_PP_OBSTRUCT(...) __VA_ARGS__ UP_PP_DEFER(UP_PP_EMPTY)()

#define UP_DETAIL_PP_EVALUATE_III(...) __VA_ARGS__
#define UP_DETAIL_PP_EVALUATE_II(...) UP_DETAIL_PP_EVALUATE_III(UP_DETAIL_PP_EVALUATE_III(UP_DETAIL_PP_EVALUATE_III(UP_DETAIL_PP_EVALUATE_III(__VA_ARGS__))))
#define UP_DETAIL_PP_EVALUATE_I(...) UP_DETAIL_PP_EVALUATE_II(UP_DETAIL_PP_EVALUATE_II(UP_DETAIL_PP_EVALUATE_II(UP_DETAIL_PP_EVALUATE_II(__VA_ARGS__))))
#define UP_PP_EVALUATE(...) UP_DETAIL_PP_EVALUATE_I(UP_DETAIL_PP_EVALUATE_I(UP_DETAIL_PP_EVALUATE_I(UP_DETAIL_PP_EVALUATE_I(__VA_ARGS__))))

#define UP_DETAIL_PP_CHECK(x, n, ...) n
#define UP_PP_CHECK(...) UP_DETAIL_PP_CHECK(__VA_ARGS__, 0,)
#define UP_PP_PROBE(x) x, 1,

#define UP_PP_BITNOT_0 1
#define UP_PP_BITNOT_1 0
#define UP_PP_BITNOT(x) UP_PP_CAT(UP_PP_BITNOT_, x)

#define UP_PP_BITAND_00 0
#define UP_PP_BITAND_01 0
#define UP_PP_BITAND_10 0
#define UP_PP_BITAND_11 1
#define UP_PP_BITAND(x, y) UP_PP_CAT(UP_PP_CAT(UP_PP_BITAND_, x), y)

#define UP_PP_BITOR_00 0
#define UP_PP_BITOR_01 1
#define UP_PP_BITOR_10 1
#define UP_PP_BITOR_11 1
#define UP_PP_BITOR(x, y) UP_PP_CAT(UP_PP_CAT(UP_PP_BITOR_, x), y)

#define UP_PP_BITXOR_00 0
#define UP_PP_BITXOR_01 1
#define UP_PP_BITXOR_10 1
#define UP_PP_BITXOR_11 0
#define UP_PP_BITXOR(x, y) UP_PP_CAT(UP_PP_CAT(UP_PP_BITXOR_, x), y)

#define UP_PP_IIF_0(x, y) y
#define UP_PP_IIF_1(x, y) x
#define UP_PP_IIF(c, x, y) UP_PP_CAT(UP_PP_IIF_, c)(x, y)

#define UP_PP_COMMA_IIF(c) UP_PP_IIF(c, UP_PP_COMMA, UP_PP_EMPTY)()
#define UP_PP_BITSELECT(c) UP_PP_IIF(c, UP_PP_FIRST, UP_PP_REST)
#define UP_PP_BITWHEN(c) UP_PP_IIF(c, UP_PP_EXPAND, UP_PP_EAT)

#define UP_PP_NOT_0 UP_PP_PROBE(~)
#define UP_PP_NOT(x) UP_PP_CHECK(UP_PP_CAT(UP_PP_NOT_, x))
#define UP_PP_BOOL(x) UP_PP_BITNOT(UP_PP_NOT(x))

#define UP_PP_AND(x, y) UP_PP_BITAND(UP_PP_BOOL(x), UP_PP_BOOL(y))
#define UP_PP_OR(x, y) UP_PP_BITOR(UP_PP_BOOL(x), UP_PP_BOOL(y))
#define UP_PP_XOR(x, y) UP_PP_BITXOR(UP_PP_BOOL(x), UP_PP_BOOL(y))
#define UP_PP_IF(c, x, y) UP_PP_IIF(UP_PP_BOOL(c), x, y)
#define UP_PP_COMMA_IF(c) UP_PP_COMMA_IIF(UP_PP_BOOL(c))
#define UP_PP_SELECT(c) UP_PP_BITSELECT(UP_PP_BOOL(c))
#define UP_PP_WHEN(c) UP_PP_BITWHEN(UP_PP_BOOL(c))

#define UP_PP_INC_0 1
#define UP_PP_INC_1 2
#define UP_PP_INC_2 3
#define UP_PP_INC_3 4
#define UP_PP_INC_4 5
#define UP_PP_INC_5 6
#define UP_PP_INC_6 7
#define UP_PP_INC_7 8
#define UP_PP_INC_8 9
#define UP_PP_INC_9 10
#define UP_PP_INC_10 11
#define UP_PP_INC_11 12
#define UP_PP_INC_12 13
#define UP_PP_INC_13 14
#define UP_PP_INC_14 15
#define UP_PP_INC_15 16
#define UP_PP_INC_16 17
#define UP_PP_INC_17 18
#define UP_PP_INC_18 19
#define UP_PP_INC_19 20
#define UP_PP_INC_20 21
#define UP_PP_INC_21 22
#define UP_PP_INC_22 23
#define UP_PP_INC_23 24
#define UP_PP_INC_24 25
#define UP_PP_INC_25 26
#define UP_PP_INC_26 27
#define UP_PP_INC_27 28
#define UP_PP_INC_28 29
#define UP_PP_INC_29 30
#define UP_PP_INC_30 31
#define UP_PP_INC_31 32
#define UP_PP_INC_32 33
#define UP_PP_INC(x) UP_PP_CAT(UP_PP_INC_, x)

#define UP_PP_DEC_0 0
#define UP_PP_DEC_1 0
#define UP_PP_DEC_2 1
#define UP_PP_DEC_3 2
#define UP_PP_DEC_4 3
#define UP_PP_DEC_5 4
#define UP_PP_DEC_6 5
#define UP_PP_DEC_7 6
#define UP_PP_DEC_8 7
#define UP_PP_DEC_9 8
#define UP_PP_DEC_10 9
#define UP_PP_DEC_11 10
#define UP_PP_DEC_12 11
#define UP_PP_DEC_13 12
#define UP_PP_DEC_14 13
#define UP_PP_DEC_15 14
#define UP_PP_DEC_16 15
#define UP_PP_DEC_17 16
#define UP_PP_DEC_18 17
#define UP_PP_DEC_19 18
#define UP_PP_DEC_20 19
#define UP_PP_DEC_21 20
#define UP_PP_DEC_22 21
#define UP_PP_DEC_23 22
#define UP_PP_DEC_24 23
#define UP_PP_DEC_25 24
#define UP_PP_DEC_26 25
#define UP_PP_DEC_27 26
#define UP_PP_DEC_28 27
#define UP_PP_DEC_29 28
#define UP_PP_DEC_30 29
#define UP_PP_DEC_31 30
#define UP_PP_DEC_32 31
#define UP_PP_DEC(x) UP_PP_CAT(UP_PP_DEC_, x)

#define UP_PP_COMPARE_0(x) x
#define UP_PP_COMPARE_1(x) x
#define UP_PP_COMPARE_2(x) x
#define UP_PP_COMPARE_2(x) x
#define UP_PP_COMPARE_3(x) x
#define UP_PP_COMPARE_4(x) x
#define UP_PP_COMPARE_5(x) x
#define UP_PP_COMPARE_6(x) x
#define UP_PP_COMPARE_7(x) x
#define UP_PP_COMPARE_8(x) x
#define UP_PP_COMPARE_9(x) x
#define UP_PP_COMPARE_10(x) x
#define UP_PP_COMPARE_11(x) x
#define UP_PP_COMPARE_12(x) x
#define UP_PP_COMPARE_12(x) x
#define UP_PP_COMPARE_13(x) x
#define UP_PP_COMPARE_14(x) x
#define UP_PP_COMPARE_15(x) x
#define UP_PP_COMPARE_16(x) x
#define UP_PP_COMPARE_17(x) x
#define UP_PP_COMPARE_18(x) x
#define UP_PP_COMPARE_19(x) x
#define UP_PP_COMPARE_20(x) x
#define UP_PP_COMPARE_21(x) x
#define UP_PP_COMPARE_22(x) x
#define UP_PP_COMPARE_22(x) x
#define UP_PP_COMPARE_23(x) x
#define UP_PP_COMPARE_24(x) x
#define UP_PP_COMPARE_25(x) x
#define UP_PP_COMPARE_26(x) x
#define UP_PP_COMPARE_27(x) x
#define UP_PP_COMPARE_28(x) x
#define UP_PP_COMPARE_29(x) x
#define UP_PP_COMPARE_30(x) x
#define UP_PP_COMPARE_31(x) x
#define UP_PP_COMPARE_32(x) x
#define UP_PP_IS_COMPARABLE(x) UP_PP_IS_TUPLE(UP_PP_CAT(UP_PP_COMPARE_, x)(()))

#define UP_DETAIL_PP_NOT_EQUAL(x, y) UP_PP_IS_TUPLE(UP_PP_COMPARE_ ## x( UP_PP_COMPARE_ ## y )(()))
#define UP_PP_NOT_EQUAL(x, y) UP_PP_IIF(UP_PP_BITAND(UP_PP_IS_COMPARABLE(x), UP_PP_IS_COMPARABLE(y)), UP_DETAIL_PP_NOT_EQUAL, 1 UP_PP_EAT)(x, y)
#define UP_PP_EQUAL(x, y) UP_PP_BITNOT(UP_PP_NOT_EQUAL(x, y))

#define UP_DETAIL_PP_EXPAND_R(...) __VA_ARGS__
#define UP_DETAIL_PP_EAT_R(...)
#define UP_DETAIL_PP_FIRST_R(x, ...) x
#define UP_DETAIL_PP_REST_R(x, ...) __VA_ARGS__

#define UP_PP_REPEAT_R(count, macro, ...) \
UP_PP_IIF(UP_PP_BOOL(count), UP_DETAIL_PP_EXPAND_R, UP_DETAIL_PP_EAT_R)( \
UP_PP_OBSTRUCT(UP_DETAIL_PP_REPEAT_INDIRECT)()(UP_PP_DEC(count), macro, __VA_ARGS__) \
UP_PP_OBSTRUCT(macro)(UP_PP_DEC(count), __VA_ARGS__) \
)

#define UP_DETAIL_PP_REPEAT_INDIRECT() UP_PP_REPEAT_R
#define UP_PP_REPEAT(count, macro, ...) UP_PP_EVALUATE(UP_PP_REPEAT_R(count, macro, __VA_ARGS__))

#define UP_PP_REPEAT_FROM_TO_R(first, last, macro, ...) \
UP_PP_IIF(UP_PP_NOT_EQUAL(first, last), UP_DETAIL_PP_EXPAND_R, UP_DETAIL_PP_EAT_R)( \
UP_PP_OBSTRUCT(UP_DETAIL_PP_REPEAT_FROM_TO_INDIRECT)()(first, UP_PP_DEC(last), macro, __VA_ARGS__) \
UP_PP_OBSTRUCT(macro)(UP_PP_DEC(last), __VA_ARGS__) \
)

#define UP_DETAIL_PP_REPEAT_FROM_TO_INDIRECT() UP_PP_REPEAT_FROM_TO_R
#define UP_PP_REPEAT_FROM_TO(first, last, macro, ...) UP_PP_EVALUATE(UP_PP_REPEAT_FROM_TO_R(first, last, macro, __VA_ARGS__))

#define UP_PP_WHILE_R(predicate, macro, ...) \
UP_PP_IIF(UP_PP_BOOL(predicate(__VA_ARGS__)), UP_DETAIL_PP_FIRST_R, UP_DETAIL_PP_REST_R)( \
UP_PP_DEFER(UP_DETAIL_PP_WHILE_INDIRECT)()(predicate, macro, macro(__VA_ARGS__)), \
__VA_ARGS__ \
)

#define UP_DETAIL_PP_WHILE_INDIRECT() UP_PP_WHILE_R
#define UP_PP_WHILE(predicate, macro, ...) UP_PP_EVALUATE(UP_PP_WHILE_R(predicate, macro, __VA_ARGS__))

#define UP_DETAIL_PP_SIZE(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29,e30,e31,n,...) n
#define UP_PP_SIZE(...) UP_DETAIL_PP_SIZE(__VA_ARGS__,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,)

#define UP_PP_ELEM_0(e0,...) e0
#define UP_PP_ELEM_1(e0,e1,...) e1
#define UP_PP_ELEM_2(e0,e1,e2,...) e2
#define UP_PP_ELEM_3(e0,e1,e2,e3,...) e3
#define UP_PP_ELEM_4(e0,e1,e2,e3,e4,...) e4
#define UP_PP_ELEM_5(e0,e1,e2,e3,e4,e5,...) e5
#define UP_PP_ELEM_6(e0,e1,e2,e3,e4,e5,e6,...) e6
#define UP_PP_ELEM_7(e0,e1,e2,e3,e4,e5,e6,e7,...) e7
#define UP_PP_ELEM_8(e0,e1,e2,e3,e4,e5,e6,e7,e8,...) e8
#define UP_PP_ELEM_9(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,...) e9
#define UP_PP_ELEM_10(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,...) e10
#define UP_PP_ELEM_11(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,...) e11
#define UP_PP_ELEM_12(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,...) e12
#define UP_PP_ELEM_13(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,...) e13
#define UP_PP_ELEM_14(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,...) e14
#define UP_PP_ELEM_15(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,...) e15
#define UP_PP_ELEM_16(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,...) e16
#define UP_PP_ELEM_17(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,...) e17
#define UP_PP_ELEM_18(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,...) e18
#define UP_PP_ELEM_19(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,...) e19
#define UP_PP_ELEM_20(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,...) e20
#define UP_PP_ELEM_21(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,...) e21
#define UP_PP_ELEM_22(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,...) e22
#define UP_PP_ELEM_23(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,...) e23
#define UP_PP_ELEM_24(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,...) e24
#define UP_PP_ELEM_25(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,...) e25
#define UP_PP_ELEM_26(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,...) e26
#define UP_PP_ELEM_27(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,...) e27
#define UP_PP_ELEM_28(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,...) e28
#define UP_PP_ELEM_29(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29,...) e29
#define UP_PP_ELEM_30(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29,e30,...) e30
#define UP_PP_ELEM_31(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29,e30,e31,...) e31
#define UP_PP_ELEM(i, ...) UP_PP_CAT(UP_PP_ELEM_, i)(__VA_ARGS__)
#define UP_PP_ELEM_N(n, i, ...) UP_PP_CAT(UP_PP_ELEM_, i)(__VA_ARGS__)

#define UP_PP_JOIN_1(e0) e0
#define UP_PP_JOIN_2(e0,e1) UP_PP_CAT(e0,e1)
#define UP_PP_JOIN_3(e0,e1,e2) UP_PP_CAT(UP_PP_CAT(e0,e1),e2)
#define UP_PP_JOIN_4(e0,e1,e2,e3) UP_PP_CAT(UP_PP_JOIN_3(e0,e1,e2),e3)
#define UP_PP_JOIN_5(e0,e1,e2,e3,e4) UP_PP_CAT(UP_PP_JOIN_4(e0,e1,e2,e3),e4)
#define UP_PP_JOIN_6(e0,e1,e2,e3,e4,e5) UP_PP_CAT(UP_PP_JOIN_5(e0,e1,e2,e3,e4),e5)
#define UP_PP_JOIN_7(e0,e1,e2,e3,e4,e5,e6) UP_PP_CAT(UP_PP_JOIN_6(e0,e1,e2,e3,e4,e5),e6)
#define UP_PP_JOIN_8(e0,e1,e2,e3,e4,e5,e6,e7) UP_PP_CAT(UP_PP_JOIN_7(e0,e1,e2,e3,e4,e5,e6),e7)
#define UP_PP_JOIN_9(e0,e1,e2,e3,e4,e5,e6,e7,e8) UP_PP_CAT(UP_PP_JOIN_8(e0,e1,e2,e3,e4,e5,e6,e7),e8)
#define UP_PP_JOIN_10(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9) UP_PP_CAT(UP_PP_JOIN_9(e0,e1,e2,e3,e4,e5,e6,e7,e8),e9)
#define UP_PP_JOIN_11(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10) UP_PP_CAT(UP_PP_JOIN_10(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9),e10)
#define UP_PP_JOIN_12(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11) UP_PP_CAT(UP_PP_JOIN_11(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10),e11)
#define UP_PP_JOIN_13(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12) UP_PP_CAT(UP_PP_JOIN_12(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11),e12)
#define UP_PP_JOIN_14(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13) UP_PP_CAT(UP_PP_JOIN_13(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12),e13)
#define UP_PP_JOIN_15(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14) UP_PP_CAT(UP_PP_JOIN_14(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13),e14)
#define UP_PP_JOIN_16(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15) UP_PP_CAT(UP_PP_JOIN_15(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14),e15)
#define UP_PP_JOIN_17(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16) UP_PP_CAT(UP_PP_JOIN_16(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15),e16)
#define UP_PP_JOIN_18(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17) UP_PP_CAT(UP_PP_JOIN_17(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16),e17)
#define UP_PP_JOIN_19(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18) UP_PP_CAT(UP_PP_JOIN_18(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17),e18)
#define UP_PP_JOIN_20(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19) UP_PP_CAT(UP_PP_JOIN_19(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18),e19)
#define UP_PP_JOIN_21(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20) UP_PP_CAT(UP_PP_JOIN_20(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19),e20)
#define UP_PP_JOIN_22(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21) UP_PP_CAT(UP_PP_JOIN_21(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20),e21)
#define UP_PP_JOIN_23(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22) UP_PP_CAT(UP_PP_JOIN_22(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21),e22)
#define UP_PP_JOIN_24(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23) UP_PP_CAT(UP_PP_JOIN_23(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22),e23)
#define UP_PP_JOIN_25(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24) UP_PP_CAT(UP_PP_JOIN_24(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23),e24)
#define UP_PP_JOIN_26(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25) UP_PP_CAT(UP_PP_JOIN_25(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24),e25)
#define UP_PP_JOIN_27(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26) UP_PP_CAT(UP_PP_JOIN_26(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25),e26)
#define UP_PP_JOIN_28(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27) UP_PP_CAT(UP_PP_JOIN_27(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26),e27)
#define UP_PP_JOIN_29(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28) UP_PP_CAT(UP_PP_JOIN_28(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27),e28)
#define UP_PP_JOIN_30(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29) UP_PP_CAT(UP_PP_JOIN_29(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28),e29)
#define UP_PP_JOIN_31(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29,e30) UP_PP_CAT(UP_PP_JOIN_30(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29),e30)
#define UP_PP_JOIN_32(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29,e30,e31) UP_PP_CAT(UP_PP_JOIN_31(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21,e22,e23,e24,e25,e26,e27,e28,e29,e30),e31)
#define UP_PP_JOIN(...) UP_PP_CAT(UP_PP_JOIN_, UP_PP_SIZE(__VA_ARGS__))(__VA_ARGS__)
#define UP_PP_JOIN_N(n, ...) UP_PP_CAT(UP_PP_JOIN_, n)(__VA_ARGS__)

#define UP_DETAIL_PP_IS_TUPLE(...) UP_PP_PROBE(~)
#define UP_PP_IS_TUPLE(t) UP_PP_CHECK(UP_DETAIL_PP_IS_TUPLE t)

#define UP_PP_TUPLE_ELEM(i, t) UP_PP_ELEM(i, UP_PP_TUPLE_ENUM(t))
#define UP_PP_TUPLE_ELEM_N(n, i, t) UP_PP_ELEM_N(n, i, UP_PP_TUPLE_ENUM(t))
#define UP_PP_TUPLE_ENUM(t) UP_PP_EXPAND(UP_PP_EXPAND t)
#define UP_PP_TUPLE_JOIN(t) UP_PP_EXPAND(UP_PP_JOIN t)
#define UP_PP_TUPLE_JOIN_N(n, t) UP_PP_JOIN_N(n, UP_PP_TUPLE_ENUM(t))
#define UP_PP_TUPLE_SIZE(t) UP_PP_EXPAND(UP_PP_SIZE t)
#define UP_PP_TO_TUPLE(...) (__VA_ARGS__)

#define UP_PP_TUPLE_FOREACH_R_N_7_c(i2, i1, i0, t0, s0, t1, s1, t2, s2, macro) macro(UP_PP_TUPLE_ELEM_N(s0, i0, t0), UP_PP_TUPLE_ELEM_N(s1, i1, t1), UP_PP_TUPLE_ELEM_N(s2, i2, t2))
#define UP_PP_TUPLE_FOREACH_R_N_7_b(i1, i0, t0, s0, t1, s1, t2, s2, macro) UP_PP_REPEAT_R(s2, UP_PP_TUPLE_FOREACH_R_N_7_c, i1, i0, t0, s0, t1, s1, t2, s2, macro)
#define UP_PP_TUPLE_FOREACH_R_N_7_a(i0, t0, s0, t1, s1, t2, s2, macro) UP_PP_REPEAT_R(s1, UP_PP_TUPLE_FOREACH_R_N_7_b, i0, t0, s0, t1, s1, t2, s2, macro)
#define UP_PP_TUPLE_FOREACH_R_N_7(t0, s0, t1, s1, t2, s2, macro) UP_PP_REPEAT_R(s0, UP_PP_TUPLE_FOREACH_R_N_7_a, t0, s0, t1, s1, t2, s2, macro)
#define UP_PP_TUPLE_FOREACH_R_N_5_b(i1, i0, t0, s0, t1, s1, macro) macro(UP_PP_TUPLE_ELEM_N(s0, i0, t0), UP_PP_TUPLE_ELEM_N(s1, i1, t1))
#define UP_PP_TUPLE_FOREACH_R_N_5_a(i0, t0, s0, t1, s1, macro) UP_PP_REPEAT_R(s1, UP_PP_TUPLE_FOREACH_R_N_5_b, i0, t0, s0, t1, s1, macro)
#define UP_PP_TUPLE_FOREACH_R_N_5(t0, s0, t1, s1, macro) UP_PP_REPEAT_R(s0, UP_PP_TUPLE_FOREACH_R_N_5_a, t0, s0, t1, s1, macro)
#define UP_PP_TUPLE_FOREACH_R_N_3_a(i0, t0, s0, macro) macro(UP_PP_TUPLE_ELEM_N(s0, i0, t0))
#define UP_PP_TUPLE_FOREACH_R_N_3(t0, s0, macro) UP_PP_REPEAT_R(s0, UP_PP_TUPLE_FOREACH_R_N_3_a, t0, s0, macro)
#define UP_PP_TUPLE_FOREACH_R_N(...) UP_PP_CAT(UP_PP_TUPLE_FOREACH_R_N_, UP_PP_SIZE(__VA_ARGS__))(__VA_ARGS__)
#define UP_PP_TUPLE_FOREACH_N(...) UP_PP_EVALUATE(UP_PP_TUPLE_FOREACH_R_N(__VA_ARGS__))

#define UP_PP_TUPLE_FOREACH_R_4(t0, t1, t2, macro) UP_PP_TUPLE_FOREACH_R_N_7(t0, UP_PP_TUPLE_SIZE(t0), t1, UP_PP_TUPLE_SIZE(t1), t2, UP_PP_TUPLE_SIZE(t2), macro)
#define UP_PP_TUPLE_FOREACH_R_3(t0, t1, macro) UP_PP_TUPLE_FOREACH_R_N_5(t0, UP_PP_TUPLE_SIZE(t0), t1, UP_PP_TUPLE_SIZE(t1), macro)
#define UP_PP_TUPLE_FOREACH_R_2(t0, macro) UP_PP_TUPLE_FOREACH_R_N_3(t0, UP_PP_TUPLE_SIZE(t0), macro)
#define UP_PP_TUPLE_FOREACH_R(...) UP_PP_CAT(UP_PP_TUPLE_FOREACH_R_, UP_PP_SIZE(__VA_ARGS__))(__VA_ARGS__)
#define UP_PP_TUPLE_FOREACH(...) UP_PP_EVALUATE(UP_PP_TUPLE_FOREACH_R(__VA_ARGS__))

Name: Anonymous 2014-03-09 5:59

dear fucking god

Name: Anonymous 2014-03-09 7:32

this is incredible.

Name: Anonymous 2014-03-09 8:11

What in the nine hells is this used for?

Name: Anonymous 2014-03-09 9:31

ONE DWORD: ENTERPRISE QUALITY

Name: Anonymous 2014-03-09 14:56

#define UP_PP_INC_n n+1
What the fuck is the point of that

Name: Anonymous 2014-03-09 19:28

hint:

#define INC(X) UP_PP_INC##X

Name: Anonymous 2014-03-09 20:46

>>4
It is used for all sorts of things. For example, I'm targetting some old compilers for some obscure platforms, and I don't have always have access to C++11 features. No problem.

// In void.h:

#ifndef UP_VARIADIC_DEFAULT_ARGUMENT_COUNT
# define UP_VARIADIC_DEFAULT_ARGUMENT_COUNT 8
#endif

#ifndef UP_NO_VARIADIC_TEMPLATES
# define UP_VARIADIC_GENERATE(first, last, macro) macro(N)
# define UP_VARIADIC_GENERATE_0N(macro) macro(N)
# define UP_VARIADIC_GENERATE_1N(macro) macro(N)
# define UP_VARIADIC_GENERATE_2N(macro) macro(N)
# define UP_VARIADIC_DECLARE_PARAMETERS(n) class... Args
# define UP_VARIADIC_FORWARD_PARAMETERS(n) Args...
# define UP_VARIADIC_DECLARE_ARGUMENTS(n) Args&&... args
# define UP_VARIADIC_DECLVAL_ARGUMENTS(n) ::up::declval<Args>()...
# define UP_VARIADIC_FORWARD_ARGUMENTS(n) ::up::forward<Args>(args)...
# define UP_VARIADIC_MOVE_ARGUMENTS(n) ::up::move(args)...
# define UP_VARIADIC_ARGUMENT_COUNT_PARAMETER size_t N
# define UP_VARIADIC_SIZEOF(n) sizeof...(Args)
#else
# define UP_DETAIL_VARIADIC_GENERATE(n, macro) macro(n)
# define UP_DETAIL_VARIADIC_DECLARE_PARAMETER(n, _) UP_PP_COMMA_IF(n) class A##n
# define UP_DETAIL_VARIADIC_FORWARD_PARAMETER(n, _) UP_PP_COMMA_IF(n) A##n
# define UP_DETAIL_VARIADIC_DECLARE_ARGUMENT(n, _) UP_PP_COMMA_IF(n) UPFORWARDREF(A##n) a##n
# define UP_DETAIL_VARIADIC_DECLVAL_ARGUMENT(n, _) UP_PP_COMMA_IF(n) ::up::declval<A##n>()
# define UP_DETAIL_VARIADIC_FORWARD_ARGUMENT(n, _) UP_PP_COMMA_IF(n) UPFORWARD(A##n)(a##n)
# define UP_DETAIL_VARIADIC_MOVE_ARGUMENT(n, _) UP_PP_COMMA_IF(n) ::up::move(a##n)
# define UP_VARIADIC_GENERATE(first, last, macro) UP_PP_REPEAT_FROM_TO(first, last, UP_DETAIL_VARIADIC_GENERATE, macro)
# define UP_VARIADIC_GENERATE_0N(macro) UP_PP_REPEAT(UP_PP_INC(UP_VARIADIC_DEFAULT_ARGUMENT_COUNT), UP_DETAIL_VARIADIC_GENERATE, macro)
# define UP_VARIADIC_GENERATE_1N(macro) UP_PP_REPEAT_FROM_TO(1, UP_PP_INC(UP_VARIADIC_DEFAULT_ARGUMENT_COUNT), UP_DETAIL_VARIADIC_GENERATE, macro)
# define UP_VARIADIC_GENERATE_2N(macro) UP_PP_REPEAT_FROM_TO(2, UP_PP_INC(UP_VARIADIC_DEFAULT_ARGUMENT_COUNT), UP_DETAIL_VARIADIC_GENERATE, macro)
# define UP_VARIADIC_DECLARE_PARAMETERS(n) UP_PP_REPEAT_R(n, UP_DETAIL_VARIADIC_DECLARE_PARAMETER, ~)
# define UP_VARIADIC_FORWARD_PARAMETERS(n) UP_PP_REPEAT_R(n, UP_DETAIL_VARIADIC_FORWARD_PARAMETER, ~)
# define UP_VARIADIC_DECLARE_ARGUMENTS(n) UP_PP_REPEAT_R(n, UP_DETAIL_VARIADIC_DECLARE_ARGUMENT, ~)
# define UP_VARIADIC_DECLVAL_ARGUMENTS(n) UP_PP_REPEAT_R(n, UP_DETAIL_VARIADIC_DECLVAL_ARGUMENT, ~)
# define UP_VARIADIC_FORWARD_ARGUMENTS(n) UP_PP_REPEAT_R(n, UP_DETAIL_VARIADIC_FORWARD_ARGUMENT, ~)
# define UP_VARIADIC_MOVE_ARGUMENTS(n) UP_PP_REPEAT_R(n, UP_DETAIL_VARIADIC_MOVE_ARGUMENT, ~)
# define UP_VARIADIC_ARGUMENT_COUNT_PARAMETER
# define UP_VARIADIC_SIZEOF(n) n
#endif

#define UP_VARIADIC_COMMA_DECLARE_PARAMETERS(n) UP_PP_COMMA_IF(n) UP_VARIADIC_DECLARE_PARAMETERS(n)
#define UP_VARIADIC_COMMA_FORWARD_PARAMETERS(n) UP_PP_COMMA_IF(n) UP_VARIADIC_FORWARD_PARAMETERS(n)
#define UP_VARIADIC_COMMA_DECLARE_ARGUMENTS(n) UP_PP_COMMA_IF(n) UP_VARIADIC_DECLARE_ARGUMENTS(n)
#define UP_VARIADIC_COMMA_DECLVAL_ARGUMENTS(n) UP_PP_COMMA_IF(n) UP_VARIADIC_DECLVAL_ARGUMENTS(n)
#define UP_VARIADIC_COMMA_FORWARD_ARGUMENTS(n) UP_PP_COMMA_IF(n) UP_VARIADIC_FORWARD_ARGUMENTS(n)
#define UP_VARIADIC_COMMA_MOVE_ARGUMENTS(n) UP_PP_COMMA_IF(n) UP_VARIADIC_MOVE_ARGUMENTS(n)

// Example:

#define UP_DETAIL_DEFINE_ALLOCATE_CONSTRUCT(ArgCount) \
template <class T, class Alloc, UP_VARIADIC_DECLARE_PARAMETERS(ArgCount)> \
inline T* allocate_construct(Alloc& a, UP_VARIADIC_DECLARE_ARGUMENTS(ArgCount)) { \
typedef detail::allocate_construct_impl<T, Alloc, is_nothrow_constructible<T, UP_VARIADIC_FORWARD_PARAMETERS(ArgCount)>::value> impl; \
return impl::template allocate_construct(a, UP_VARIADIC_FORWARD_ARGUMENTS(ArgCount)); \
}

UP_VARIADIC_GENERATE_1N(UP_DETAIL_DEFINE_ALLOCATE_CONSTRUCT)
#undef UP_DETAIL_DEFINE_ALLOCATE_CONSTRUCT

// Is equivalent too:

template <class T, class Alloc, class... Args>
inline T* allocate_construct(Alloc& a, Args&&... args) {
typedef detail::allocate_construct_impl<T, Alloc, is_nothrow_constructible<T, Args...>::value> impl;
return impl::template allocate_construct(a, ::up::forward<Args>(args)...);
}

Name: Anonymous 2014-03-10 9:19

Reminds of c++'s boost. They used a lot of macro shit there coupled with unusual use of templates.

Name: Anonymous 2014-03-10 13:22

>>8
In void.h
All is explained.

Name: Anonymous 2014-03-10 14:03

void.h
Oh boy, here we go again.
Also, there's this: https://github.com/orangeduck/CPP_COMPLETE

Name: Anonymous 2014-03-10 16:41

One of the most useless macros I've seen:

#define VOID void

In <windows.h> IIRC.

Name: Anonymous 2014-03-14 1:32

>>12
What about WORD, DWORD, LPCSTR, and all that faggotry.

Name: Anonymous 2014-03-15 6:00

>>11
Enterprise ready code. Just get a faster CPU and you can develop a CRM in preprocessor.

>>13
http://en.wikipedia.org/wiki/Not_invented_here

Name: sage 2014-03-29 22:53

>>13
I think that was Microsoft's way of making C look more like the macro assembler all its programmers were accustomed to at the time.

Name: Anonymous 2014-03-30 6:22

>>15

Agreed. Back in early 90ies, everything was written in MASM and TASM, because C/C++ is just too slow for 1MHz 16bit CPU, with too little memory to facilitate far jumps, required by C/C++.

Name: Anonymous 2014-03-31 15:33

>>16
8086 compilers in the 80s and early 90s also sucked. The Watcom compiler (and MSVC as well, I believe) actually generates pretty good code and can handle mixed near/far calls in the same program.

Name: Anonymous 2014-04-05 17:04

Those aren't even macros, just the lame C nuisance misnomer.

Name: Anonymous 2014-04-05 17:48

>>18
Misnomer? That implies the existence of an earlier use of the word `macro' for programming that C's notion contradicts. But from what I can tell, the earliest origin of the term `macro' comes from assembly macros: for example the [i]705 Autocoder System Macro-Instruction Manual[/i], of which a copy is retained at https://archive.org/details/bitsavers_ibm7053274Instrs1957_6769339 .

Macro-Instructions are easily written commands to the Autocoder which cause it to create sequences of machine instructions to carry out certain commonly used functions. A typical macro-instruction consists of a single line entry writen by the programmer in the same format as a 705 instruction. It will automatically cause the generation of from one to more than a dozen 705 instructions and may also call in desired subroutines of hundreds of instructions.

Browsing through the examples, they seem very similar to C preprocessor macros - a single line is typed, with a few operands, and from what I can determine the Autocoder system fully replaced the line of that macro with other lines, with the operands substituded in at regular intervals. Am I missing something?

Name: Anonymous 2014-04-06 8:19

>>19
If you want real macros, learn Lisp. All other "macros" are decoys, misnomers, nuisances, pieces of shit.

Name: Anonymous 2014-04-06 12:51

>>20
If you want real macros, learn Perl6. All other "macros" are decoys, misnomers, nuisances, pieces of shit.

Name: Anonymous 2014-04-06 15:14

>>21
If you want real macros, learn Macro Brainfuck. All other "macros" are decoys, misnomers, nuisances, pieces of shit.

Name: Anonymous 2014-04-06 15:34

>>22
If you want real Macross, watch SDF. All other "Robotech" is a decoy, a misnomer, a nuisance, a piece of shit.

Name: Anonymous 2014-04-07 20:40

>>23
I loved your post.

Name: Anonymous 2014-04-08 12:50

FASM macros are Turing complete by themselves.

Name: Anonymous 2014-04-10 3:51

>>25
IIRC nasm supports recursive macros as well.

gas' macro syntax is rather limited, but you can pair it with m4. Oddly enough it's also popular to just write a Perl script that prints gas code when evaluated...

Name: Anonymous 2014-04-10 4:41

>>26
Why not just use C? If you use a lot of macros. A C-compiler can optimize your code, but assembler just outputs whatever the shit your macro commands it to output (which is probably slower.)

Name: Anonymous 2014-04-10 5:17

>>27
Of course, if you are using assembler it's a good idea to know why first.

Name: Anonymous 2014-04-10 9:27

Of course, if you are penetrating an anus it's a good idea to know why first.

Name: Anonymous 2014-04-12 1:34

>>25
I remember seeing a Fasm macro `program' that compiled to a bitmap of the an image Mandelbrot set of the given dimensions and level of detail, but I can't find it, despite searching those forums back until 2005, when I think I saw it. I recall it was only about 50 lines, but they were called recursively, so it took several minutes to be assembled. Does anyone have it?

Name: Anonymous 2014-04-12 7:02

>>27
Because C doesn't have macros. Only Lisp has them.

Name: Anonymous 2014-04-12 7:06

>>31
If ``only'' Lisp has macros, and Lisp's use of the term ``macro'' isn't even the first, wouldn't it make sense to just use another term for Lisp's macros? That way you don't have to get butthurt when people talk about macros without mentioning Lisp.

Name: Anonymous 2014-04-12 9:21

>>32
Lisp macros are the first real macros. Meanings of words change, so the word macro should only refer to Lisp macros, not to the primitive unhygienic text substitution. Use "text preprocessing" instead of "C macros".

Name: Anonymous 2014-04-12 12:40

>>33
No, that would be stupid. How about we call the things Lisp has ``Lisp macros'' because they are (according to you) so unique, and we'll call everything else just plain ``macros''.

Oh, would you look at that. We already do. So stop whining and bringing up irrelevant concepts.

Name: Anonymous 2014-04-12 19:48

>>34

You're either

A. Really stupid
B. A troll
C. An uneducated shill
D. All the above

Name: Anonymous 2014-04-12 19:57

>>35
It's pretty obvious you're just flamebaiting, since you aren't even bothering to not bump.

Name: Anonymous 2014-04-12 20:08

>>32,34,36
'
>le pedophile sage
>le pedophile criticism


>>31,33,35
'
>le faggot face

Name: Anonymous 2014-04-12 20:53

>>37
You've cum! ^-^

Name: Anonymous 2014-04-12 23:11

>>38
Is it on my face? ^-^

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List