1 | # /* **************************************************************************
|
---|
2 | # * *
|
---|
3 | # * (C) Copyright Paul Mensonides 2002.
|
---|
4 | # * Distributed under the Boost Software License, Version 1.0. (See
|
---|
5 | # * accompanying file LICENSE_1_0.txt or copy at
|
---|
6 | # * http://www.boost.org/LICENSE_1_0.txt)
|
---|
7 | # * *
|
---|
8 | # ************************************************************************** */
|
---|
9 | #
|
---|
10 | # /* See http://www.boost.org for most recent version. */
|
---|
11 | #
|
---|
12 | # ifndef BOOST_PREPROCESSOR_ARRAY_INSERT_HPP
|
---|
13 | # define BOOST_PREPROCESSOR_ARRAY_INSERT_HPP
|
---|
14 | #
|
---|
15 | # include <boost/preprocessor/arithmetic/inc.hpp>
|
---|
16 | # include <boost/preprocessor/array/elem.hpp>
|
---|
17 | # include <boost/preprocessor/array/push_back.hpp>
|
---|
18 | # include <boost/preprocessor/array/size.hpp>
|
---|
19 | # include <boost/preprocessor/comparison/not_equal.hpp>
|
---|
20 | # include <boost/preprocessor/control/deduce_d.hpp>
|
---|
21 | # include <boost/preprocessor/control/iif.hpp>
|
---|
22 | # include <boost/preprocessor/control/while.hpp>
|
---|
23 | # include <boost/preprocessor/tuple/elem.hpp>
|
---|
24 | #
|
---|
25 | # /* BOOST_PP_ARRAY_INSERT */
|
---|
26 | #
|
---|
27 | # define BOOST_PP_ARRAY_INSERT(array, i, elem) BOOST_PP_ARRAY_INSERT_I(BOOST_PP_DEDUCE_D(), array, i, elem)
|
---|
28 | # define BOOST_PP_ARRAY_INSERT_I(d, array, i, elem) BOOST_PP_ARRAY_INSERT_D(d, array, i, elem)
|
---|
29 | #
|
---|
30 | # /* BOOST_PP_ARRAY_INSERT_D */
|
---|
31 | #
|
---|
32 | # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
|
---|
33 | # define BOOST_PP_ARRAY_INSERT_D(d, array, i, elem) BOOST_PP_TUPLE_ELEM(5, 3, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_INSERT_P, BOOST_PP_ARRAY_INSERT_O, (0, i, elem, (0, ()), array)))
|
---|
34 | # else
|
---|
35 | # define BOOST_PP_ARRAY_INSERT_D(d, array, i, elem) BOOST_PP_ARRAY_INSERT_D_I(d, array, i, elem)
|
---|
36 | # define BOOST_PP_ARRAY_INSERT_D_I(d, array, i, elem) BOOST_PP_TUPLE_ELEM(5, 3, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_INSERT_P, BOOST_PP_ARRAY_INSERT_O, (0, i, elem, (0, ()), array)))
|
---|
37 | # endif
|
---|
38 | #
|
---|
39 | # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()
|
---|
40 | # define BOOST_PP_ARRAY_INSERT_P(d, state) BOOST_PP_ARRAY_INSERT_P_I state
|
---|
41 | # else
|
---|
42 | # define BOOST_PP_ARRAY_INSERT_P(d, state) BOOST_PP_ARRAY_INSERT_P_I(nil, nil, nil, BOOST_PP_TUPLE_ELEM(5, 3, state), BOOST_PP_TUPLE_ELEM(5, 4, state))
|
---|
43 | # endif
|
---|
44 | #
|
---|
45 | # define BOOST_PP_ARRAY_INSERT_P_I(_i, _ii, _iii, res, arr) BOOST_PP_NOT_EQUAL(BOOST_PP_ARRAY_SIZE(res), BOOST_PP_INC(BOOST_PP_ARRAY_SIZE(arr)))
|
---|
46 | #
|
---|
47 | # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()
|
---|
48 | # define BOOST_PP_ARRAY_INSERT_O(d, state) BOOST_PP_ARRAY_INSERT_O_I state
|
---|
49 | # else
|
---|
50 | # define BOOST_PP_ARRAY_INSERT_O(d, state) BOOST_PP_ARRAY_INSERT_O_I(BOOST_PP_TUPLE_ELEM(5, 0, state), BOOST_PP_TUPLE_ELEM(5, 1, state), BOOST_PP_TUPLE_ELEM(5, 2, state), BOOST_PP_TUPLE_ELEM(5, 3, state), BOOST_PP_TUPLE_ELEM(5, 4, state))
|
---|
51 | # endif
|
---|
52 | #
|
---|
53 | # define BOOST_PP_ARRAY_INSERT_O_I(n, i, elem, res, arr) (BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(BOOST_PP_ARRAY_SIZE(res), i), BOOST_PP_INC(n), n), i, elem, BOOST_PP_ARRAY_PUSH_BACK(res, BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(BOOST_PP_ARRAY_SIZE(res), i), BOOST_PP_ARRAY_ELEM(n, arr), elem)), arr)
|
---|
54 | #
|
---|
55 | # endif
|
---|