Skip to the content.

:warning: macro/expand_tails.hpp

Depends on

Code

#pragma once


#include "macro/basic.hpp"
#include "macro/loop.hpp"

#define EXPAND_TAILS_IMPL(base, tail) UNPAREN base UNPAREN tail

#define EXPAND_TAILS_AUX_1(base, tails) EXPAND_TAILS_IMPL(base, tails)
#define EXPAND_TAILS_AUX_2(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_1(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_3(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_2(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_4(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_3(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_5(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_4(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_6(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_5(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_7(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_6(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_8(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_7(base, __VA_ARGS__)

#define EXPAND_TAILS(base, ...) CONCAT(EXPAND_TAILS_AUX_, VA_ARGS_SIZE(__VA_ARGS__))(base, __VA_ARGS__)
#line 2 "macro/expand_tails.hpp"


#line 2 "macro/basic.hpp"

#define TO_STRING_AUX(x) #x
#define TO_STRING(x) TO_STRING_AUX(x)

#define CONCAT_AUX(x, y) x##y
#define CONCAT(x, y) CONCAT_AUX(x, y)

#define UNPAREN_AUX(...) __VA_ARGS__
#define UNPAREN(...) __VA_ARGS__
#line 2 "macro/loop.hpp"


#define INDEX_RSEQ() 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0

#define VA_ARGS_SIZE_IMPL(ARG1,  ARG2,  ARG3,  ARG4,  ARG5,  ARG6,  ARG7,  ARG8,  ARG9,  ARG10, ARG11, ARG12, ARG13, ARG14, ARG15, ARG16, N, ...) N

#define VA_ARGS_SIZE_AUX(...) VA_ARGS_SIZE_IMPL(__VA_ARGS__)
#define VA_ARGS_SIZE(...) VA_ARGS_SIZE_AUX(__VA_ARGS__, INDEX_RSEQ())
#line 6 "macro/expand_tails.hpp"

#define EXPAND_TAILS_IMPL(base, tail) UNPAREN base UNPAREN tail

#define EXPAND_TAILS_AUX_1(base, tails) EXPAND_TAILS_IMPL(base, tails)
#define EXPAND_TAILS_AUX_2(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_1(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_3(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_2(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_4(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_3(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_5(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_4(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_6(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_5(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_7(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_6(base, __VA_ARGS__)
#define EXPAND_TAILS_AUX_8(base, tails, ...) EXPAND_TAILS_IMPL(base, tails) EXPAND_TAILS_AUX_7(base, __VA_ARGS__)

#define EXPAND_TAILS(base, ...) CONCAT(EXPAND_TAILS_AUX_, VA_ARGS_SIZE(__VA_ARGS__))(base, __VA_ARGS__)
Back to top page