1 // Copyright Cromwell D. Enage 2017. 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE_1_0.txt or copy at 4 // http://www.boost.org/LICENSE_1_0.txt) 5 6 #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_BINARY_SEQ_TO_ARGS_HPP 7 #define BOOST_PARAMETER_AUX_PREPROCESSOR_BINARY_SEQ_TO_ARGS_HPP 8 9 #include <boost/preprocessor/seq/elem.hpp> 10 #include <boost/preprocessor/cat.hpp> 11 12 #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0_1(n, prefix_seq) \ 13 BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, prefix_seq), n) const& 14 /**/ 15 16 #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1_1(n, prefix_seq) \ 17 BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, prefix_seq), n)& 18 /**/ 19 20 #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0_2(n, prefix_seq) \ 21 BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0_1(n, prefix_seq) \ 22 BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1, prefix_seq), n) 23 /**/ 24 25 #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1_2(n, prefix_seq) \ 26 BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1_1(n, prefix_seq) \ 27 BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1, prefix_seq), n) 28 /**/ 29 30 #include <boost/preprocessor/seq/size.hpp> 31 32 #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0(prefix_seq) \ 33 BOOST_PP_CAT( \ 34 BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0_ \ 35 , BOOST_PP_SEQ_SIZE(prefix_seq) \ 36 ) 37 /**/ 38 39 #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1(prefix_seq) \ 40 BOOST_PP_CAT( \ 41 BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1_ \ 42 , BOOST_PP_SEQ_SIZE(prefix_seq) \ 43 ) 44 /**/ 45 46 #include <boost/parameter/aux_/preprocessor/convert_binary_seq.hpp> 47 48 // This macro converts the specified Boost.Preprocessor sequence of 1s and 0s 49 // into a formal function parameter list. 50 // 51 // Example: 52 // BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARGS((1)(0)(1)(0), (P)(p)) 53 // expands to 54 // P0 & p0, P1 const& p1, P2 & p2, P3 const& p3 55 #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARGS(binary_seq, prefix_seq) \ 56 BOOST_PARAMETER_AUX_PP_CONVERT_BINARY_SEQ( \ 57 binary_seq \ 58 , BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0(prefix_seq) \ 59 , BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1(prefix_seq) \ 60 , prefix_seq \ 61 ) 62 /**/ 63 64 #endif // include guard 65 66