mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-23 09:07:26 +02:00
Factoring out the workaround to access last variadic parameter.
Indeed when some parameter are BOOST_PP_EMPTY the last parameter is accessed correctly but results in a compilation error which doesn't stop some compiler (e.g. g++) to go through the preprocessing pass and still compile the binary correctly. But to avoid the error message I used a workaround which behaves better. I preferred factoring it out to make clear that there are some reason why this element is strangely accessed.
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp>
|
||||
|
||||
#include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
#include <boost/preprocessor/control/if.hpp>
|
||||
#include <boost/preprocessor/logical/or.hpp>
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
@ -53,13 +54,18 @@
|
||||
BOOST_PP_IS_EMPTY(BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__))), \
|
||||
BOOST_FUSION_ADAPT_ADT_WRAP_ATTR( \
|
||||
BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__), \
|
||||
BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_REST_N(3, \
|
||||
BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))) ), \
|
||||
BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(__VA_ARGS__) \
|
||||
), \
|
||||
BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(__VA_ARGS__))
|
||||
|
||||
# define BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(...) \
|
||||
((BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__)))
|
||||
|
||||
# define BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(...) \
|
||||
BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_REST_N( \
|
||||
BOOST_PP_SUB(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), 1), \
|
||||
BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)))
|
||||
|
||||
#else // BOOST_PP_VARIADICS
|
||||
|
||||
# define BOOST_FUSION_ADAPT_ADT_FILLER_0(A, B, C, D) \
|
||||
|
Reference in New Issue
Block a user