1 # /* Copyright (C) 2001 2 # * Housemarque Oy 3 # * http://www.housemarque.com 4 # * 5 # * Distributed under the Boost Software License, Version 1.0. (See 6 # * accompanying file LICENSE_1_0.txt or copy at 7 # * http://www.boost.org/LICENSE_1_0.txt) 8 # */ 9 # 10 # /* Revised by Paul Mensonides (2002) */ 11 # /* Revised by Edward Diener (2020) */ 12 # 13 # /* See http://www.boost.org for most recent version. */ 14 # 15 # ifndef BOOST_PREPROCESSOR_ARITHMETIC_SUB_HPP 16 # define BOOST_PREPROCESSOR_ARITHMETIC_SUB_HPP 17 # 18 # include <boost/preprocessor/config/config.hpp> 19 # 20 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() 21 # 22 # include <boost/preprocessor/arithmetic/dec.hpp> 23 # include <boost/preprocessor/control/while.hpp> 24 # include <boost/preprocessor/tuple/elem.hpp> 25 # 26 # /* BOOST_PP_SUB */ 27 # 28 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() 29 # define BOOST_PP_SUB(x, y) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE(BOOST_PP_SUB_P, BOOST_PP_SUB_O, (x, y))) 30 # else 31 # define BOOST_PP_SUB(x, y) BOOST_PP_SUB_I(x, y) 32 # define BOOST_PP_SUB_I(x, y) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE(BOOST_PP_SUB_P, BOOST_PP_SUB_O, (x, y))) 33 # endif 34 # 35 # define BOOST_PP_SUB_P(d, xy) BOOST_PP_TUPLE_ELEM(2, 1, xy) 36 # 37 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() 38 # define BOOST_PP_SUB_O(d, xy) BOOST_PP_SUB_O_I xy 39 # else 40 # define BOOST_PP_SUB_O(d, xy) BOOST_PP_SUB_O_I(BOOST_PP_TUPLE_ELEM(2, 0, xy), BOOST_PP_TUPLE_ELEM(2, 1, xy)) 41 # endif 42 # 43 # define BOOST_PP_SUB_O_I(x, y) (BOOST_PP_DEC(x), BOOST_PP_DEC(y)) 44 # 45 # /* BOOST_PP_SUB_D */ 46 # 47 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() 48 # define BOOST_PP_SUB_D(d, x, y) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_SUB_P, BOOST_PP_SUB_O, (x, y))) 49 # else 50 # define BOOST_PP_SUB_D(d, x, y) BOOST_PP_SUB_D_I(d, x, y) 51 # define BOOST_PP_SUB_D_I(d, x, y) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_SUB_P, BOOST_PP_SUB_O, (x, y))) 52 # endif 53 # 54 # else 55 # 56 # include <boost/preprocessor/arithmetic/dec.hpp> 57 # include <boost/preprocessor/control/iif.hpp> 58 # include <boost/preprocessor/control/while.hpp> 59 # include <boost/preprocessor/facilities/identity.hpp> 60 # include <boost/preprocessor/logical/and.hpp> 61 # include <boost/preprocessor/logical/bitor.hpp> 62 # include <boost/preprocessor/tuple/elem.hpp> 63 # include <boost/preprocessor/arithmetic/detail/is_maximum_number.hpp> 64 # include <boost/preprocessor/arithmetic/detail/is_minimum_number.hpp> 65 # 66 # /* BOOST_PP_SUB */ 67 # 68 # define BOOST_PP_SUB(x, y) BOOST_PP_IIF(BOOST_PP_BITOR(BOOST_PP_DETAIL_IS_MAXIMUM_NUMBER(y),BOOST_PP_DETAIL_IS_MINIMUM_NUMBER(x)),BOOST_PP_IDENTITY_N(0,2),BOOST_PP_SUB_DO)(x,y) 69 # 70 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() 71 # define BOOST_PP_SUB_DO(x, y) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE(BOOST_PP_SUB_P, BOOST_PP_SUB_O, (x, y))) 72 # else 73 # define BOOST_PP_SUB_DO(x, y) BOOST_PP_SUB_I(x, y) 74 # define BOOST_PP_SUB_I(x, y) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE(BOOST_PP_SUB_P, BOOST_PP_SUB_O, (x, y))) 75 # endif 76 # 77 # define BOOST_PP_SUB_P(d, xy) BOOST_PP_AND(BOOST_PP_TUPLE_ELEM(2, 1, xy),BOOST_PP_TUPLE_ELEM(2, 0, xy)) 78 # 79 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() 80 # define BOOST_PP_SUB_O(d, xy) BOOST_PP_SUB_O_I xy 81 # else 82 # define BOOST_PP_SUB_O(d, xy) BOOST_PP_SUB_O_I(BOOST_PP_TUPLE_ELEM(2, 0, xy), BOOST_PP_TUPLE_ELEM(2, 1, xy)) 83 # endif 84 # 85 # define BOOST_PP_SUB_O_I(x, y) (BOOST_PP_DEC(x), BOOST_PP_DEC(y)) 86 # 87 # /* BOOST_PP_SUB_D */ 88 # 89 # define BOOST_PP_SUB_D(d, x, y) BOOST_PP_IIF(BOOST_PP_BITOR(BOOST_PP_DETAIL_IS_MAXIMUM_NUMBER(y),BOOST_PP_DETAIL_IS_MINIMUM_NUMBER(x)),BOOST_PP_IDENTITY_N(0,3),BOOST_PP_SUB_DO_D)(d,x,y) 90 # 91 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() 92 # define BOOST_PP_SUB_DO_D(d, x, y) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_SUB_P, BOOST_PP_SUB_O, (x, y))) 93 # else 94 # define BOOST_PP_SUB_DO_D(d, x, y) BOOST_PP_SUB_D_I(d, x, y) 95 # define BOOST_PP_SUB_D_I(d, x, y) BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_SUB_P, BOOST_PP_SUB_O, (x, y))) 96 # endif 97 # 98 # endif 99 # 100 # endif 101