mod.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_MOD_HPP
  16. # define BOOST_PREPROCESSOR_ARITHMETIC_MOD_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/detail/div_base.hpp>
  23. # include <boost/preprocessor/tuple/elem.hpp>
  24. #
  25. # /* BOOST_PP_MOD */
  26. #
  27. # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
  28. # define BOOST_PP_MOD(x, y) BOOST_PP_TUPLE_ELEM(3, 1, BOOST_PP_DIV_BASE(x, y))
  29. # else
  30. # define BOOST_PP_MOD(x, y) BOOST_PP_MOD_I(x, y)
  31. # define BOOST_PP_MOD_I(x, y) BOOST_PP_TUPLE_ELEM(3, 1, BOOST_PP_DIV_BASE(x, y))
  32. # endif
  33. #
  34. # /* BOOST_PP_MOD_D */
  35. #
  36. # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
  37. # define BOOST_PP_MOD_D(d, x, y) BOOST_PP_TUPLE_ELEM(3, 1, BOOST_PP_DIV_BASE_D(d, x, y))
  38. # else
  39. # define BOOST_PP_MOD_D(d, x, y) BOOST_PP_MOD_D_I(d, x, y)
  40. # define BOOST_PP_MOD_D_I(d, x, y) BOOST_PP_TUPLE_ELEM(3, 1, BOOST_PP_DIV_BASE_D(d, x, y))
  41. # endif
  42. #
  43. # else
  44. #
  45. # include <boost/preprocessor/arithmetic/detail/div_base.hpp>
  46. # include <boost/preprocessor/control/iif.hpp>
  47. # include <boost/preprocessor/facilities/identity.hpp>
  48. # include <boost/preprocessor/tuple/elem.hpp>
  49. # include <boost/preprocessor/arithmetic/detail/is_1_number.hpp>
  50. #
  51. # /* BOOST_PP_MOD */
  52. #
  53. # define BOOST_PP_MOD(x, y) BOOST_PP_IIF(BOOST_PP_DETAIL_IS_1_NUMBER(y),BOOST_PP_IDENTITY_N(0,2),BOOST_PP_MOD_DO)(x,y)
  54. #
  55. # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
  56. # define BOOST_PP_MOD_DO(x, y) BOOST_PP_TUPLE_ELEM(3, 1, BOOST_PP_DIV_BASE(x, y))
  57. # else
  58. # define BOOST_PP_MOD_DO(x, y) BOOST_PP_MOD_I(x, y)
  59. # define BOOST_PP_MOD_I(x, y) BOOST_PP_TUPLE_ELEM(3, 1, BOOST_PP_DIV_BASE(x, y))
  60. # endif
  61. #
  62. # /* BOOST_PP_MOD_D */
  63. #
  64. # define BOOST_PP_MOD_D(d, x, y) BOOST_PP_IIF(BOOST_PP_DETAIL_IS_1_NUMBER(y),BOOST_PP_IDENTITY_N(0,3),BOOST_PP_MOD_DO_D)(d,x,y)
  65. #
  66. # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
  67. # define BOOST_PP_MOD_DO_D(d, x, y) BOOST_PP_TUPLE_ELEM(3, 1, BOOST_PP_DIV_BASE_D(d, x, y))
  68. # else
  69. # define BOOST_PP_MOD_DO_D(d, x, y) BOOST_PP_MOD_D_I(d, x, y)
  70. # define BOOST_PP_MOD_D_I(d, x, y) BOOST_PP_TUPLE_ELEM(3, 1, BOOST_PP_DIV_BASE_D(d, x, y))
  71. # endif
  72. #
  73. # endif
  74. #
  75. # endif