transform.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_SEQ_TRANSFORM_HPP
  13. # define BOOST_PREPROCESSOR_SEQ_TRANSFORM_HPP
  14. #
  15. # include <boost/preprocessor/config/config.hpp>
  16. # include <boost/preprocessor/seq/fold_left.hpp>
  17. # include <boost/preprocessor/seq/seq.hpp>
  18. # include <boost/preprocessor/tuple/elem.hpp>
  19. # include <boost/preprocessor/tuple/rem.hpp>
  20. #
  21. # /* BOOST_PP_SEQ_TRANSFORM */
  22. #
  23. # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
  24. # define BOOST_PP_SEQ_TRANSFORM(op, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT(BOOST_PP_SEQ_TRANSFORM_O, (op, data, (nil)), seq)))
  25. # else
  26. # define BOOST_PP_SEQ_TRANSFORM(op, data, seq) BOOST_PP_SEQ_TRANSFORM_I(op, data, seq)
  27. # define BOOST_PP_SEQ_TRANSFORM_I(op, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT(BOOST_PP_SEQ_TRANSFORM_O, (op, data, (nil)), seq)))
  28. # endif
  29. #
  30. # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()
  31. # define BOOST_PP_SEQ_TRANSFORM_O(s, state, elem) BOOST_PP_SEQ_TRANSFORM_O_IM(s, BOOST_PP_TUPLE_REM_3 state, elem)
  32. # define BOOST_PP_SEQ_TRANSFORM_O_IM(s, im, elem) BOOST_PP_SEQ_TRANSFORM_O_I(s, im, elem)
  33. # else
  34. # define BOOST_PP_SEQ_TRANSFORM_O(s, state, elem) BOOST_PP_SEQ_TRANSFORM_O_I(s, BOOST_PP_TUPLE_ELEM(3, 0, state), BOOST_PP_TUPLE_ELEM(3, 1, state), BOOST_PP_TUPLE_ELEM(3, 2, state), elem)
  35. # endif
  36. #
  37. # define BOOST_PP_SEQ_TRANSFORM_O_I(s, op, data, res, elem) (op, data, res (op(s, data, elem)))
  38. #
  39. # /* BOOST_PP_SEQ_TRANSFORM_S */
  40. #
  41. # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
  42. # define BOOST_PP_SEQ_TRANSFORM_S(s, op, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT_ ## s(BOOST_PP_SEQ_TRANSFORM_O, (op, data, (nil)), seq)))
  43. # else
  44. # define BOOST_PP_SEQ_TRANSFORM_S(s, op, data, seq) BOOST_PP_SEQ_TRANSFORM_S_I(s, op, data, seq)
  45. # define BOOST_PP_SEQ_TRANSFORM_S_I(s, op, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT_ ## s(BOOST_PP_SEQ_TRANSFORM_O, (op, data, (nil)), seq)))
  46. # endif
  47. #
  48. # endif