adapt_base_attr_filler.hpp 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*=============================================================================
  2. Copyright (c) 2013-2014 Damien Buhl
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #ifndef BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP
  7. #define BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP
  8. #include <boost/config.hpp>
  9. #include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
  10. #include <boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp>
  11. #include <boost/mpl/aux_/preprocessor/token_equal.hpp>
  12. #include <boost/preprocessor/arithmetic/dec.hpp>
  13. #include <boost/preprocessor/control/iif.hpp>
  14. #include <boost/preprocessor/logical/or.hpp>
  15. #include <boost/preprocessor/tuple/elem.hpp>
  16. #include <boost/preprocessor/variadic/to_seq.hpp>
  17. #include <boost/preprocessor/variadic/size.hpp>
  18. #include <boost/preprocessor/variadic/elem.hpp>
  19. #include <boost/preprocessor/seq/seq.hpp>
  20. #include <boost/preprocessor/seq/rest_n.hpp>
  21. #define BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE) \
  22. BOOST_PP_TUPLE_ELEM(2, 0, ATTRIBUTE)
  23. #define BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR(ATTRIBUTE) \
  24. BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE)
  25. #if BOOST_PP_VARIADICS
  26. # define BOOST_FUSION_ADAPT_ADT_FILLER_0(...) \
  27. BOOST_FUSION_ADAPT_ADT_FILLER(__VA_ARGS__) \
  28. BOOST_FUSION_ADAPT_ADT_FILLER_1
  29. # define BOOST_FUSION_ADAPT_ADT_FILLER_1(...) \
  30. BOOST_FUSION_ADAPT_ADT_FILLER(__VA_ARGS__) \
  31. BOOST_FUSION_ADAPT_ADT_FILLER_0
  32. # define BOOST_FUSION_ADAPT_ADT_FILLER_0_END
  33. # define BOOST_FUSION_ADAPT_ADT_FILLER_1_END
  34. // MSVC don't compile when using BOOST_PP_BITOR instead of BOOST_PP_OR.
  35. # define BOOST_FUSION_ADAPT_ADT_FILLER(...) \
  36. BOOST_PP_IIF( \
  37. BOOST_PP_OR( \
  38. BOOST_MPL_PP_TOKEN_EQUAL(auto, \
  39. BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)), \
  40. BOOST_MPL_PP_TOKEN_EQUAL(auto, \
  41. BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__))), \
  42. \
  43. BOOST_FUSION_ADAPT_ADT_WRAP_ATTR( \
  44. BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__), \
  45. BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(__VA_ARGS__) \
  46. ), \
  47. BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(__VA_ARGS__))
  48. # define BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(...) \
  49. ((BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__)))
  50. # define BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(...) \
  51. BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_REST_N( \
  52. BOOST_PP_DEC(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__)), \
  53. BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)))
  54. #else // BOOST_PP_VARIADICS
  55. # define BOOST_FUSION_ADAPT_ADT_FILLER_0(A, B, C, D) \
  56. BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A,B,C,D) \
  57. BOOST_FUSION_ADAPT_ADT_FILLER_1
  58. # define BOOST_FUSION_ADAPT_ADT_FILLER_1(A, B, C, D) \
  59. BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A,B,C,D) \
  60. BOOST_FUSION_ADAPT_ADT_FILLER_0
  61. # define BOOST_FUSION_ADAPT_ADT_FILLER_0_END
  62. # define BOOST_FUSION_ADAPT_ADT_FILLER_1_END
  63. # define BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A, B, C, D) \
  64. BOOST_PP_IIF(BOOST_MPL_PP_TOKEN_EQUAL(auto, A), \
  65. ((2, (C,D))), \
  66. ((4, (A,B,C,D))) \
  67. )
  68. #endif // BOOST_PP_VARIADICS
  69. #endif