pp_arity_loop.hpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // (C) Copyright Tobias Schwinger
  2. //
  3. // Use modification and distribution are subject to the boost Software License,
  4. // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
  5. //------------------------------------------------------------------------------
  6. // no include guards, this file is intended for multiple inclusion
  7. #ifndef BOOST_FT_PREPROCESSING_MODE
  8. // input: BOOST_FT_mfp 0 or 1 <=> member function pointer?
  9. // input: BOOST_FT_type_name BOOST_FT_type --> "R (* ..._type_name)()" (pass2)
  10. #endif
  11. // input: BOOST_FT_syntax type macro to use
  12. // input: BOOST_FT_cc empty or cc specifier
  13. // input: BOOST_FT_ell empty or "..."
  14. // input: BOOST_FT_cv empty or cv qualifiers
  15. // input: BOOST_FT_flags single decimal integer encoding the flags
  16. // output: BOOST_FT_n number of component types (arity+1)
  17. // output: BOOST_FT_arity current arity
  18. // output: BOOST_FT_type macro that expands to the type
  19. // output: BOOST_FT_tplargs(p) template arguments with given prefix
  20. // output: BOOST_FT_params(p) parameters with given prefix
  21. #ifdef __WAVE__
  22. # pragma wave option(preserve: 0)
  23. #endif
  24. #ifndef BOOST_FT_ARITY_LOOP_IS_ITERATING
  25. # define BOOST_FT_AL_PREPROCESSED \
  26. BOOST_FT_AL_FILE(BOOST_FT_al_path,BOOST_FT_FROM_ARITY,BOOST_FT_mfp)
  27. # define BOOST_FT_AL_FILE(base_path,max_arity,mfp) \
  28. BOOST_FT_AL_FILE_I(base_path,max_arity,mfp)
  29. # define BOOST_FT_AL_FILE_I(base_path,max_arity,mfp) \
  30. <base_path/arity ## max_arity ## _ ## mfp.hpp>
  31. # if !defined(BOOST_FT_PREPROCESSING_MODE)
  32. # if BOOST_FT_MAX_ARITY < 10
  33. # define BOOST_FT_FROM_ARITY 0
  34. # elif BOOST_FT_MAX_ARITY < 20
  35. # define BOOST_FT_FROM_ARITY 10
  36. # elif BOOST_FT_MAX_ARITY < 30
  37. # define BOOST_FT_FROM_ARITY 20
  38. # elif BOOST_FT_MAX_ARITY < 40
  39. # define BOOST_FT_FROM_ARITY 30
  40. # endif
  41. # if BOOST_FT_FROM_ARITY
  42. # include BOOST_FT_AL_PREPROCESSED
  43. # endif
  44. # elif !defined(BOOST_FT_FROM_ARITY) // single pass preprocessing
  45. # define BOOST_FT_FROM_ARITY 0
  46. # elif BOOST_FT_FROM_ARITY > 0 // arity20 includes arity10
  47. BOOST_PP_EXPAND(#) include BOOST_FT_AL_PREPROCESSED
  48. # endif
  49. # undef BOOST_FT_AL_PREPROCESSED
  50. # undef BOOST_FT_AL_FILE
  51. # undef BOOST_FT_AL_FILE_I
  52. # if BOOST_FT_MAX_ARITY > BOOST_FT_FROM_ARITY
  53. # ifndef BOOST_FT_DETAIL_ARITY_LOOP_HPP_INCLUDED
  54. # define BOOST_FT_DETAIL_ARITY_LOOP_HPP_INCLUDED
  55. # include <boost/preprocessor/cat.hpp>
  56. # include <boost/preprocessor/tuple/eat.hpp>
  57. # include <boost/preprocessor/control/if.hpp>
  58. # include <boost/preprocessor/arithmetic/inc.hpp>
  59. # include <boost/preprocessor/facilities/empty.hpp>
  60. # include <boost/preprocessor/facilities/expand.hpp>
  61. # include <boost/preprocessor/iteration/iterate.hpp>
  62. # include <boost/preprocessor/repetition/enum_params.hpp>
  63. # include <boost/preprocessor/repetition/enum_shifted_params.hpp>
  64. # include <boost/preprocessor/repetition/enum_trailing_params.hpp>
  65. # endif
  66. # define BOOST_FT_AL_INCLUDE_FILE <BOOST_FT_al_path/master.hpp>
  67. # define BOOST_FT_ARITY_LOOP_PREFIX 1
  68. # include BOOST_FT_AL_INCLUDE_FILE
  69. # undef BOOST_FT_ARITY_LOOP_PREFIX
  70. # if !BOOST_PP_IS_ITERATING
  71. # define BOOST_PP_FILENAME_1 BOOST_FT_AL_INCLUDE_FILE
  72. # elif BOOST_PP_ITERATION_DEPTH() == 1
  73. # define BOOST_PP_FILENAME_2 BOOST_FT_AL_INCLUDE_FILE
  74. # else
  75. # error "loops nested too deeply"
  76. # endif
  77. # define BOOST_FT_arity BOOST_PP_ITERATION()
  78. # define BOOST_FT_n BOOST_PP_INC(BOOST_FT_arity)
  79. # define BOOST_FT_type \
  80. BOOST_FT_syntax(BOOST_FT_cc,BOOST_FT_type_name BOOST_PP_EMPTY)\
  81. (BOOST_FT_params(BOOST_PP_EMPTY) BOOST_FT_ell) BOOST_FT_cv
  82. # define BOOST_FT_tplargs(prefx) \
  83. prefx() R BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_FT_arity,prefx() T)
  84. # if !BOOST_FT_mfp
  85. # define BOOST_FT_params(prefx) \
  86. BOOST_PP_IF(BOOST_FT_arity,BOOST_PP_ENUM_PARAMS, \
  87. BOOST_FT_nullary_param BOOST_PP_TUPLE_EAT(2))( \
  88. BOOST_FT_arity,prefx() T)
  89. # else
  90. # define BOOST_FT_params(prefx) \
  91. BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_FT_arity,prefx() T)
  92. # endif
  93. # if !BOOST_FT_FROM_ARITY
  94. # define BOOST_PP_ITERATION_LIMITS (BOOST_FT_mfp, BOOST_FT_MAX_ARITY)
  95. # else
  96. # define BOOST_PP_ITERATION_LIMITS \
  97. (BOOST_FT_FROM_ARITY+1, BOOST_FT_MAX_ARITY)
  98. # endif
  99. # define BOOST_FT_ARITY_LOOP_IS_ITERATING 1
  100. # include BOOST_PP_ITERATE()
  101. # undef BOOST_FT_ARITY_LOOP_IS_ITERATING
  102. # undef BOOST_FT_arity
  103. # undef BOOST_FT_params
  104. # undef BOOST_FT_tplargs
  105. # undef BOOST_FT_type
  106. # define BOOST_FT_ARITY_LOOP_SUFFIX 1
  107. # include BOOST_FT_AL_INCLUDE_FILE
  108. # undef BOOST_FT_ARITY_LOOP_SUFFIX
  109. # undef BOOST_FT_AL_INCLUDE_FILE
  110. # endif
  111. # undef BOOST_FT_FROM_ARITY
  112. #else
  113. # error "attempt to nest arity loops"
  114. #endif