Created
April 22, 2020 16:22
-
-
Save nlyan/33755c59bf31c3f3b986b5392d54fba6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/preprocessor.hpp> | |
// the magic | |
#define MAGIC_PLACEHOLDER_FILLER_0(X, Y) ((X, Y)) MAGIC_PLACEHOLDER_FILLER_1 | |
#define MAGIC_PLACEHOLDER_FILLER_1(X, Y) ((X, Y)) MAGIC_PLACEHOLDER_FILLER_0 | |
#define MAGIC_PLACEHOLDER_FILLER_0_END | |
#define MAGIC_PLACEHOLDER_FILLER_1_END | |
// example usage | |
#define MAGIC2(Z, N, ARGS) \ | |
{ BOOST_PP_REMOVE_PARENS (BOOST_PP_SEQ_ELEM (N, ARGS)) } | |
#define MAGIC(EXPRS) \ | |
BOOST_PP_ENUM (BOOST_PP_SEQ_SIZE (BOOST_PP_VARIADIC_SEQ_TO_SEQ (EXPRS)), \ | |
MAGIC2, \ | |
BOOST_PP_CAT (MAGIC_PLACEHOLDER_FILLER_0 EXPRS, _END)) | |
MAGIC ((42, "security") (101, "price") (102, "volume")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment