1 /*============================================================================= 2 Copyright (c) 2013-2014 Damien Buhl 3 4 Distributed under the Boost Software License, Version 1.0. (See accompanying 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 ==============================================================================*/ 7 8 #ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ASSOC_ATTR_FILLER_HPP 9 #define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ASSOC_ATTR_FILLER_HPP 10 11 #include <boost/config.hpp> 12 13 #include <boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp> 14 15 #include <boost/preprocessor/control/if.hpp> 16 #include <boost/preprocessor/arithmetic/sub.hpp> 17 #include <boost/preprocessor/variadic/size.hpp> 18 #include <boost/preprocessor/empty.hpp> 19 #include <boost/preprocessor/facilities/is_empty.hpp> 20 21 #if BOOST_PP_VARIADICS 22 23 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(...) \ 24 BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(__VA_ARGS__) \ 25 BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1 26 27 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1(...) \ 28 BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(__VA_ARGS__) \ 29 BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0 30 31 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(...) \ 32 ((BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))) 33 34 #else // BOOST_PP_VARIADICS 35 36 37 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(X, Y, Z) \ 38 BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(X, Y, Z) \ 39 BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1 40 41 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1(X, Y, Z) \ 42 BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(X, Y, Z) \ 43 BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0 44 45 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(X, Y, Z) \ 46 BOOST_PP_IF(BOOST_PP_IS_EMPTY(X), \ 47 ((2, (Y,Z))), \ 48 ((3, (X,Y,Z))) \ 49 ) 50 51 #endif // BOOST_PP_VARIADICS 52 53 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0_END 54 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1_END 55 56 57 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAPPEDATTR_GET_KEY(ATTRIBUTE) \ 58 BOOST_PP_TUPLE_ELEM( \ 59 BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), \ 60 BOOST_PP_SUB(BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), 1), \ 61 BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE)) 62 63 #endif 64