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 # /* Revised by Edward Diener (2020) */ 11 # 12 # /* See http://www.boost.org for most recent version. */ 13 # 14 # ifndef BOOST_PREPROCESSOR_ARRAY_REMOVE_HPP 15 # define BOOST_PREPROCESSOR_ARRAY_REMOVE_HPP 16 # 17 # include <boost/preprocessor/config/config.hpp> 18 # 19 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() 20 # 21 # include <boost/preprocessor/arithmetic/inc.hpp> 22 # include <boost/preprocessor/array/elem.hpp> 23 # include <boost/preprocessor/array/push_back.hpp> 24 # include <boost/preprocessor/array/size.hpp> 25 # include <boost/preprocessor/comparison/not_equal.hpp> 26 # include <boost/preprocessor/control/deduce_d.hpp> 27 # include <boost/preprocessor/control/iif.hpp> 28 # include <boost/preprocessor/control/while.hpp> 29 # include <boost/preprocessor/tuple/eat.hpp> 30 # include <boost/preprocessor/tuple/elem.hpp> 31 # 32 # /* BOOST_PP_ARRAY_REMOVE */ 33 # 34 # define BOOST_PP_ARRAY_REMOVE(array, i) BOOST_PP_ARRAY_REMOVE_I(BOOST_PP_DEDUCE_D(), array, i) 35 # define BOOST_PP_ARRAY_REMOVE_I(d, array, i) BOOST_PP_ARRAY_REMOVE_D(d, array, i) 36 # 37 # /* BOOST_PP_ARRAY_REMOVE_D */ 38 # 39 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() 40 # define BOOST_PP_ARRAY_REMOVE_D(d, array, i) BOOST_PP_TUPLE_ELEM(4, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_REMOVE_P, BOOST_PP_ARRAY_REMOVE_O, (0, i, (0, ()), array))) 41 # else 42 # define BOOST_PP_ARRAY_REMOVE_D(d, array, i) BOOST_PP_ARRAY_REMOVE_D_I(d, array, i) 43 # define BOOST_PP_ARRAY_REMOVE_D_I(d, array, i) BOOST_PP_TUPLE_ELEM(4, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_REMOVE_P, BOOST_PP_ARRAY_REMOVE_O, (0, i, (0, ()), array))) 44 # endif 45 # 46 # define BOOST_PP_ARRAY_REMOVE_P(d, st) BOOST_PP_NOT_EQUAL(BOOST_PP_TUPLE_ELEM(4, 0, st), BOOST_PP_ARRAY_SIZE(BOOST_PP_TUPLE_ELEM(4, 3, st))) 47 # 48 # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() 49 # define BOOST_PP_ARRAY_REMOVE_O(d, st) BOOST_PP_ARRAY_REMOVE_O_I st 50 # else 51 # define BOOST_PP_ARRAY_REMOVE_O(d, st) BOOST_PP_ARRAY_REMOVE_O_I(BOOST_PP_TUPLE_ELEM(4, 0, st), BOOST_PP_TUPLE_ELEM(4, 1, st), BOOST_PP_TUPLE_ELEM(4, 2, st), BOOST_PP_TUPLE_ELEM(4, 3, st)) 52 # endif 53 # 54 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC() 55 # define BOOST_PP_ARRAY_REMOVE_O_I(n, i, res, arr) (BOOST_PP_INC(n), i, BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(n, i), BOOST_PP_ARRAY_PUSH_BACK, res BOOST_PP_TUPLE_EAT_2)(res, BOOST_PP_ARRAY_ELEM(n, arr)), arr) 56 # else 57 # define BOOST_PP_ARRAY_REMOVE_O_I(n, i, res, arr) (BOOST_PP_INC(n), i, BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(n, i), BOOST_PP_ARRAY_PUSH_BACK, BOOST_PP_TUPLE_ELEM_2_0)(res, BOOST_PP_ARRAY_ELEM(n, arr)), arr) 58 # endif 59 # 60 # else 61 # 62 # include <boost/preprocessor/arithmetic/inc.hpp> 63 # include <boost/preprocessor/array/elem.hpp> 64 # include <boost/preprocessor/array/push_back.hpp> 65 # include <boost/preprocessor/array/size.hpp> 66 # include <boost/preprocessor/comparison/not_equal.hpp> 67 # include <boost/preprocessor/control/deduce_d.hpp> 68 # include <boost/preprocessor/control/iif.hpp> 69 # include <boost/preprocessor/control/while.hpp> 70 # if BOOST_PP_LIMIT_TUPLE == 256 71 # include <boost/preprocessor/logical/not.hpp> 72 # endif 73 # include <boost/preprocessor/tuple/eat.hpp> 74 # include <boost/preprocessor/tuple/elem.hpp> 75 # 76 # /* BOOST_PP_ARRAY_REMOVE */ 77 # 78 # define BOOST_PP_ARRAY_REMOVE(array, i) BOOST_PP_ARRAY_REMOVE_I(BOOST_PP_DEDUCE_D(), array, i) 79 # define BOOST_PP_ARRAY_REMOVE_I(d, array, i) BOOST_PP_ARRAY_REMOVE_D(d, array, i) 80 # 81 # /* BOOST_PP_ARRAY_REMOVE_D */ 82 # 83 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() 84 # if BOOST_PP_LIMIT_TUPLE == 256 85 # define BOOST_PP_ARRAY_REMOVE_D(d, array, i) BOOST_PP_ARRAY_REMOVE_ZERO_D(d, array, i, BOOST_PP_NOT(i)) 86 # else 87 # define BOOST_PP_ARRAY_REMOVE_D(d, array, i) BOOST_PP_TUPLE_ELEM(4, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_REMOVE_P, BOOST_PP_ARRAY_REMOVE_O, (0, i, (0, ()), array))) 88 # endif 89 # else 90 # define BOOST_PP_ARRAY_REMOVE_D(d, array, i) BOOST_PP_ARRAY_REMOVE_D_I(d, array, i) 91 # if BOOST_PP_LIMIT_TUPLE == 256 92 # define BOOST_PP_ARRAY_REMOVE_D_I(d, array, i) BOOST_PP_ARRAY_REMOVE_ZERO_D(d, array, i, BOOST_PP_NOT(i)) 93 # else 94 # define BOOST_PP_ARRAY_REMOVE_D_I(d, array, i) BOOST_PP_TUPLE_ELEM(4, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_REMOVE_P, BOOST_PP_ARRAY_REMOVE_O, (0, i, (0, ()), array))) 95 # endif 96 # endif 97 # 98 # if BOOST_PP_LIMIT_TUPLE == 256 99 # define BOOST_PP_ARRAY_REMOVE_ZERO_D(d, array, i, zero) \ 100 BOOST_PP_TUPLE_ELEM(4, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_ARRAY_REMOVE_P, BOOST_PP_ARRAY_REMOVE_O, \ 101 (1, i, BOOST_PP_IIF(zero,(0, ()),(1, (BOOST_PP_ARRAY_ELEM(0,array)))), array))) 102 # endif 103 # 104 # define BOOST_PP_ARRAY_REMOVE_P(d, st) BOOST_PP_NOT_EQUAL(BOOST_PP_TUPLE_ELEM(4, 0, st), BOOST_PP_ARRAY_SIZE(BOOST_PP_TUPLE_ELEM(4, 3, st))) 105 # 106 # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() 107 # define BOOST_PP_ARRAY_REMOVE_O(d, st) BOOST_PP_ARRAY_REMOVE_O_I st 108 # else 109 # define BOOST_PP_ARRAY_REMOVE_O(d, st) BOOST_PP_ARRAY_REMOVE_O_I(BOOST_PP_TUPLE_ELEM(4, 0, st), BOOST_PP_TUPLE_ELEM(4, 1, st), BOOST_PP_TUPLE_ELEM(4, 2, st), BOOST_PP_TUPLE_ELEM(4, 3, st)) 110 # endif 111 # 112 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC() 113 # define BOOST_PP_ARRAY_REMOVE_O_I(n, i, res, arr) (BOOST_PP_INC(n), i, BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(n, i), BOOST_PP_ARRAY_PUSH_BACK, res BOOST_PP_TUPLE_EAT_2)(res, BOOST_PP_ARRAY_ELEM(n, arr)), arr) 114 # else 115 # define BOOST_PP_ARRAY_REMOVE_O_I(n, i, res, arr) (BOOST_PP_INC(n), i, BOOST_PP_IIF(BOOST_PP_NOT_EQUAL(n, i), BOOST_PP_ARRAY_PUSH_BACK, BOOST_PP_TUPLE_ELEM_2_0)(res, BOOST_PP_ARRAY_ELEM(n, arr)), arr) 116 # endif 117 # 118 # endif 119 # 120 # endif 121