forked from boostorg/preprocessor
Updated arithmetic implementations to deal with corner cases whichy run out of WHILE loops.
This commit is contained in:
1 parent
d41d1dda97
commit
13c9669410
6 files changed
+80
-28
No files matched your search
@@ -19,6 +19,10 @@
|
||||
# include <boost/preprocessor/config/config.hpp>
|
||||
# include <boost/preprocessor/control/iif.hpp>
|
||||
# include <boost/preprocessor/control/while.hpp>
|
||||
# include <boost/preprocessor/facilities/identity.hpp>
|
||||
# include <boost/preprocessor/logical/bitand.hpp>
|
||||
# include <boost/preprocessor/logical/bool.hpp>
|
||||
# include <boost/preprocessor/logical/compl.hpp>
|
||||
# include <boost/preprocessor/tuple/elem.hpp>
|
||||
# include <boost/preprocessor/tuple/rem.hpp>
|
||||
# include <boost/preprocessor/arithmetic/detail/is_minimum_number.hpp>
|
||||
@@ -26,9 +30,9 @@
|
||||
#
|
||||
# /* BOOST_PP_MUL */
|
||||
#
|
||||
# define BOOST_PP_MUL(x, y) BOOST_PP_IIF(BOOST_PP_DETAIL_IS_MAXIMUM_NUMBER(y),BOOST_PP_MUL_CHECK_MIN,BOOST_PP_MUL_DO)(x,y)
|
||||
# define BOOST_PP_MUL(x, y) BOOST_PP_IIF(BOOST_PP_DETAIL_IS_MINIMUM_NUMBER(x),BOOST_PP_IDENTITY_N(x,2),BOOST_PP_MUL_CHECK_MAX)(x,y)
|
||||
#
|
||||
# define BOOST_PP_MUL_CHECK_MIN(x,y) BOOST_PP_IIF(BOOST_PP_DETAIL_IS_MINIMUM_NUMBER(x),0,BOOST_PP_DETAIL_MAXIMUM_NUMBER)
|
||||
# define BOOST_PP_MUL_CHECK_MAX(x, y) BOOST_PP_IIF(BOOST_PP_DETAIL_IS_MAXIMUM_NUMBER(y),BOOST_PP_IDENTITY_N(y,2),BOOST_PP_MUL_DO)(x,y)
|
||||
#
|
||||
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
|
||||
# define BOOST_PP_MUL_DO(x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_WHILE(BOOST_PP_MUL_P, BOOST_PP_MUL_O, (0, x, y)))
|
||||
@@ -37,7 +41,7 @@
|
||||
# define BOOST_PP_MUL_I(x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_WHILE(BOOST_PP_MUL_P, BOOST_PP_MUL_O, (0, x, y)))
|
||||
# endif
|
||||
#
|
||||
# define BOOST_PP_MUL_P(d, rxy) BOOST_PP_TUPLE_ELEM(3, 2, rxy)
|
||||
# define BOOST_PP_MUL_P(d, rxy) BOOST_PP_BITAND(BOOST_PP_BOOL(BOOST_PP_TUPLE_ELEM(3, 2, rxy)),BOOST_PP_COMPL(BOOST_PP_DETAIL_IS_MAXIMUM_NUMBER(BOOST_PP_TUPLE_ELEM(3, 0, rxy))))
|
||||
#
|
||||
# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()
|
||||
# define BOOST_PP_MUL_O(d, rxy) BOOST_PP_MUL_O_IM(d, BOOST_PP_TUPLE_REM_3 rxy)
|
||||
@@ -50,9 +54,9 @@
|
||||
#
|
||||
# /* BOOST_PP_MUL_D */
|
||||
#
|
||||
# define BOOST_PP_MUL_D(d, x, y) BOOST_PP_IIF(BOOST_PP_DETAIL_IS_MAXIMUM_NUMBER(y),BOOST_PP_MUL_CHECK_MIN_D,BOOST_PP_MUL_DO_D)(d,x,y)
|
||||
# define BOOST_PP_MUL_D(d, x, y) BOOST_PP_IIF(BOOST_PP_DETAIL_IS_MINIMUM_NUMBER(x),BOOST_PP_IDENTITY_N(x,3),BOOST_PP_MUL_CHECK_MAX_D)(d,x,y)
|
||||
#
|
||||
# define BOOST_PP_MUL_CHECK_MIN_D(d,x,y) BOOST_PP_IIF(BOOST_PP_DETAIL_IS_MINIMUM_NUMBER(x),0,BOOST_PP_DETAIL_MAXIMUM_NUMBER)
|
||||
# define BOOST_PP_MUL_CHECK_MAX_D(d, x, y) BOOST_PP_IIF(BOOST_PP_DETAIL_IS_MAXIMUM_NUMBER(y),BOOST_PP_IDENTITY_N(y,3),BOOST_PP_MUL_DO_D)(d,x,y)
|
||||
#
|
||||
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
|
||||
# define BOOST_PP_MUL_DO_D(d, x, y) BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_WHILE_ ## d(BOOST_PP_MUL_P, BOOST_PP_MUL_O, (0, x, y)))
|
||||
|
||||
Reference in new issue
Block a user