From aa7b0a697229305f12d89ba3f17b4ce9f909519d Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Tue, 23 Sep 2014 23:07:00 +0200 Subject: [PATCH] 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. --- .../adapted/adt/detail/adapt_base_attr_filler.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/boost/fusion/adapted/adt/detail/adapt_base_attr_filler.hpp b/include/boost/fusion/adapted/adt/detail/adapt_base_attr_filler.hpp index e88d7f1e..09bd4014 100644 --- a/include/boost/fusion/adapted/adt/detail/adapt_base_attr_filler.hpp +++ b/include/boost/fusion/adapted/adt/detail/adapt_base_attr_filler.hpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -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) \