1 // Copyright Cromwell D. Enage 2013. 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_CONVERT_BINARY_SEQ_HPP 7 #define BOOST_PARAMETER_AUX_PREPROCESSOR_CONVERT_BINARY_SEQ_HPP 8 9 #include <boost/preprocessor/seq/size.hpp> 10 #include <boost/preprocessor/seq/push_back.hpp> 11 12 #define BOOST_PARAMETER_AUX_PP_AUGMENT_BINARY_SEQ_INDEX_FOLD_OP(s, seq, idx) \ 13 BOOST_PP_SEQ_PUSH_BACK(seq, (idx, BOOST_PP_SEQ_SIZE(seq))) 14 /**/ 15 16 #include <boost/preprocessor/control/iif.hpp> 17 #include <boost/preprocessor/seq/elem.hpp> 18 #include <boost/preprocessor/tuple/elem.hpp> 19 20 #define BOOST_PARAMETER_AUX_PP_CONVERT_BINARY_SEQ_FOLD_OP(s, seq, elem) \ 21 ( \ 22 BOOST_PP_SEQ_PUSH_BACK( \ 23 BOOST_PP_SEQ_ELEM(0, seq) \ 24 , BOOST_PP_IIF( \ 25 BOOST_PP_TUPLE_ELEM(2, 0, elem) \ 26 , BOOST_PP_SEQ_ELEM(2, seq) \ 27 , BOOST_PP_SEQ_ELEM(1, seq) \ 28 )(BOOST_PP_TUPLE_ELEM(2, 1, elem), BOOST_PP_SEQ_ELEM(3, seq)) \ 29 ) \ 30 )(BOOST_PP_SEQ_ELEM(1, seq))(BOOST_PP_SEQ_ELEM(2, seq)) \ 31 (BOOST_PP_SEQ_ELEM(3, seq)) 32 /**/ 33 34 #include <boost/parameter/aux_/preprocessor/seq_enum.hpp> 35 #include <boost/preprocessor/facilities/empty.hpp> 36 #include <boost/preprocessor/seq/seq.hpp> 37 #include <boost/preprocessor/seq/fold_left.hpp> 38 39 #define BOOST_PARAMETER_AUX_PP_CONVERT_BINARY_SEQ(seq, macro0, macro1, data) \ 40 BOOST_PARAMETER_SEQ_ENUM( \ 41 BOOST_PP_SEQ_ELEM( \ 42 0 \ 43 , BOOST_PP_SEQ_FOLD_LEFT( \ 44 BOOST_PARAMETER_AUX_PP_CONVERT_BINARY_SEQ_FOLD_OP \ 45 , (BOOST_PP_SEQ_NIL)(macro0)(macro1)(data) \ 46 , BOOST_PP_SEQ_FOLD_LEFT( \ 47 BOOST_PARAMETER_AUX_PP_AUGMENT_BINARY_SEQ_INDEX_FOLD_OP \ 48 , BOOST_PP_EMPTY() \ 49 , seq \ 50 ) \ 51 ) \ 52 ) \ 53 ) 54 /**/ 55 56 #endif // include guard 57 58