| 1 | // Copyright Daniel Wallin 2006. |
| 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_IMPL_SPLIT_ARGS_HPP |
| 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_SPLIT_ARGS_HPP |
| 8 | |
| 9 | #include <boost/preprocessor/tuple/elem.hpp> |
| 10 | |
| 11 | // Accessor macros for the split_args tuple. |
| 12 | #define BOOST_PARAMETER_SPLIT_ARG_REQ_COUNT(x) BOOST_PP_TUPLE_ELEM(4, 0, x) |
| 13 | #define BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ(x) BOOST_PP_TUPLE_ELEM(4, 1, x) |
| 14 | #define BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT(x) BOOST_PP_TUPLE_ELEM(4, 2, x) |
| 15 | #define BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ(x) BOOST_PP_TUPLE_ELEM(4, 3, x) |
| 16 | |
| 17 | #include <boost/preprocessor/arithmetic/inc.hpp> |
| 18 | #include <boost/preprocessor/seq/push_back.hpp> |
| 19 | |
| 20 | // Helper macros for BOOST_PARAMETER_FUNCTION_SPLIT_ARGS. |
| 21 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(s_a, arg) \ |
| 22 | ( \ |
| 23 | BOOST_PP_INC(BOOST_PARAMETER_SPLIT_ARG_REQ_COUNT(s_a)) \ |
| 24 | , BOOST_PP_SEQ_PUSH_BACK(BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ(s_a), arg) \ |
| 25 | , BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT(s_a) \ |
| 26 | , BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ(s_a) \ |
| 27 | ) |
| 28 | /**/ |
| 29 | |
| 30 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_required(split_args, arg) \ |
| 31 | BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(split_args, arg) |
| 32 | /**/ |
| 33 | |
| 34 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(s_a, arg) \ |
| 35 | ( \ |
| 36 | BOOST_PARAMETER_SPLIT_ARG_REQ_COUNT(s_a) \ |
| 37 | , BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ(s_a) \ |
| 38 | , BOOST_PP_INC(BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT(s_a)) \ |
| 39 | , BOOST_PP_SEQ_PUSH_BACK(BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ(s_a), arg) \ |
| 40 | ) |
| 41 | /**/ |
| 42 | |
| 43 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_optional(split_args, arg) \ |
| 44 | BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(split_args, arg) |
| 45 | /**/ |
| 46 | |
| 47 | #include <boost/parameter/aux_/preprocessor/impl/argument_specs.hpp> |
| 48 | #include <boost/preprocessor/cat.hpp> |
| 49 | |
| 50 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARG(s, split_args, arg) \ |
| 51 | BOOST_PP_CAT( \ |
| 52 | BOOST_PARAMETER_FUNCTION_SPLIT_ARG_ \ |
| 53 | , BOOST_PARAMETER_FN_ARG_QUALIFIER(arg) \ |
| 54 | )(split_args, arg) |
| 55 | /**/ |
| 56 | |
| 57 | #include <boost/preprocessor/seq/fold_left.hpp> |
| 58 | #include <boost/preprocessor/seq/seq.hpp> |
| 59 | |
| 60 | // Expands from the flattened BOOST_PARAMETER_FUNCTION et. al. arg sequence to |
| 61 | // the tuple (required_count, required_args, optional_count, optional_args). |
| 62 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args) \ |
| 63 | BOOST_PP_SEQ_FOLD_LEFT( \ |
| 64 | BOOST_PARAMETER_FUNCTION_SPLIT_ARG \ |
| 65 | , (0, BOOST_PP_SEQ_NIL, 0, BOOST_PP_SEQ_NIL) \ |
| 66 | , args \ |
| 67 | ) |
| 68 | /**/ |
| 69 | |
| 70 | #endif // include guard |
| 71 | |
| 72 | |