0

I want to have a macro MAC(...) which expands to all except the first argument passed to it. How do I achieve this?

My first thoughts were to convert the __VA_ARGS__ to a BOOST_PP_TUPLE and then do a POP_FRONT operation:

#define MAC(...)\
  BOOST_PP_TUPLE_POP_FRONT(BOOST_PP_VARIADIC_TO_TUPLE(__VA_ARGS__))
MAC(1,2,3)

But this simply expands to

BOOST_PP_TUPLE_POP_FRONT((1,2,3))

I tried adding the BOOST_PP_EXPAND macro:

#define MAC(...)\
  BOOST_PP_EXPAND(\
    BOOST_PP_TUPLE_POP_FRONT BOOST_PP_VARIADIC_TO_TUPLE(__VA_ARGS__))
MAC(1,2,3)

But I get the same result. What I want is an output of

2, 3

How do I achieve this?

Using templates is not an option nor is using other libraries or tools (other than boost).

4

1 回答 1

4

你试过简单的答案吗?

#define Y(ignore, ...) __VA_ARGS__
#define X(...) Y(__VA_ARGS__)
于 2014-08-10T23:55:01.823 回答