decl.hpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef BOOST_CONTRACT_DETAIL_DECL_HPP_
  2. #define BOOST_CONTRACT_DETAIL_DECL_HPP_
  3. // Copyright (C) 2008-2018 Lorenzo Caminiti
  4. // Distributed under the Boost Software License, Version 1.0 (see accompanying
  5. // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
  6. // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
  7. // Cannot include core/*.hpp other than config.hpp here (avoid circular incl).
  8. #include <boost/contract/detail/tvariadic.hpp>
  9. #if !BOOST_CONTRACT_DETAIL_TVARIADIC
  10. #include <boost/contract/core/config.hpp>
  11. #include <boost/preprocessor/repetition/repeat.hpp>
  12. #include <boost/preprocessor/tuple/elem.hpp>
  13. #include <boost/preprocessor/arithmetic/inc.hpp>
  14. #endif
  15. #include <boost/preprocessor/control/expr_iif.hpp>
  16. #include <boost/preprocessor/control/iif.hpp>
  17. #include <boost/preprocessor/punctuation/comma_if.hpp>
  18. /* PUBLIC */
  19. #define BOOST_CONTRACT_DETAIL_DECL_OVERRIDING_PUBLIC_FUNCTION_Z(z, \
  20. arity, is_friend, has_result, \
  21. O, VR, F, C, Args, \
  22. v, r, f, obj, args \
  23. ) \
  24. template< \
  25. class O \
  26. BOOST_PP_COMMA_IF(has_result) \
  27. BOOST_PP_EXPR_IIF(has_result, typename VR) \
  28. , typename F \
  29. , class C \
  30. BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \
  31. BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(z, arity, Args) \
  32. > \
  33. BOOST_PP_EXPR_IIF(is_friend, friend) \
  34. boost::contract::specify_precondition_old_postcondition_except< \
  35. BOOST_PP_EXPR_IIF(has_result, VR)> \
  36. /* no boost::contract:: here for friends (otherwise need fwd decl) */ \
  37. public_function( \
  38. boost::contract::virtual_* v \
  39. BOOST_PP_COMMA_IF(has_result) \
  40. BOOST_PP_EXPR_IIF(has_result, VR& r) \
  41. , F f \
  42. , C* obj \
  43. BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \
  44. BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z(z, arity, Args, &, args) \
  45. )
  46. #if BOOST_CONTRACT_DETAIL_TVARIADIC
  47. #define BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTIONS_Z(z, \
  48. O, VR, F, C, Args, \
  49. v, r, f, obj, args \
  50. ) \
  51. BOOST_CONTRACT_DETAIL_DECL_OVERRIDING_PUBLIC_FUNCTION_Z(z, \
  52. ~, /* is_friend = */ 1, /* has_result = */ 0, \
  53. O, VR, F, C, Args, v, r, f, obj, args \
  54. ); \
  55. BOOST_CONTRACT_DETAIL_DECL_OVERRIDING_PUBLIC_FUNCTION_Z(z, \
  56. ~, /* is_friend = */ 1, /* has_result = */ 1, \
  57. O, VR, F, C, Args, v, r, f, obj, args \
  58. );
  59. #else
  60. /* PRIVATE */
  61. #define BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTION_( \
  62. z, n, result_O_R_F_C_Args_v_r_f_obj_args) \
  63. BOOST_CONTRACT_DETAIL_DECL_OVERRIDING_PUBLIC_FUNCTION_Z(z, \
  64. /* arity = */ n, \
  65. /* is_friend = */ 1, \
  66. BOOST_PP_TUPLE_ELEM(11, 0, result_O_R_F_C_Args_v_r_f_obj_args), \
  67. BOOST_PP_TUPLE_ELEM(11, 1, result_O_R_F_C_Args_v_r_f_obj_args), \
  68. BOOST_PP_TUPLE_ELEM(11, 2, result_O_R_F_C_Args_v_r_f_obj_args), \
  69. BOOST_PP_TUPLE_ELEM(11, 3, result_O_R_F_C_Args_v_r_f_obj_args), \
  70. BOOST_PP_TUPLE_ELEM(11, 4, result_O_R_F_C_Args_v_r_f_obj_args), \
  71. BOOST_PP_TUPLE_ELEM(11, 5, result_O_R_F_C_Args_v_r_f_obj_args), \
  72. BOOST_PP_TUPLE_ELEM(11, 6, result_O_R_F_C_Args_v_r_f_obj_args), \
  73. BOOST_PP_TUPLE_ELEM(11, 7, result_O_R_F_C_Args_v_r_f_obj_args), \
  74. BOOST_PP_TUPLE_ELEM(11, 8, result_O_R_F_C_Args_v_r_f_obj_args), \
  75. BOOST_PP_TUPLE_ELEM(11, 9, result_O_R_F_C_Args_v_r_f_obj_args), \
  76. BOOST_PP_TUPLE_ELEM(11, 10, result_O_R_F_C_Args_v_r_f_obj_args) \
  77. );
  78. /* PUBLIC */
  79. #define BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTIONS_Z(z, \
  80. O, VR, F, C, Args, \
  81. v, r, f, obj, args \
  82. ) \
  83. BOOST_PP_REPEAT_ ## z( \
  84. BOOST_PP_INC(BOOST_CONTRACT_MAX_ARGS), \
  85. BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTION_, \
  86. (/* has_result = */ 0, O, VR, F, C, Args, v, r, f, obj, args) \
  87. ) \
  88. BOOST_PP_REPEAT_ ## z( \
  89. BOOST_PP_INC(BOOST_CONTRACT_MAX_ARGS), \
  90. BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTION_, \
  91. (/* has_result = */ 1, O, VR, F, C, Args, v, r, f, obj, args) \
  92. )
  93. #endif
  94. #define BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z( \
  95. z, is_friend, O, VR, F, C, Args) \
  96. template< \
  97. class O, typename VR, typename F, class C \
  98. BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS) \
  99. BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(z, \
  100. BOOST_CONTRACT_MAX_ARGS, Args) \
  101. > \
  102. BOOST_PP_IIF(is_friend, \
  103. friend class boost::contract::detail:: \
  104. , \
  105. class \
  106. ) \
  107. cond_subcontracting
  108. /* CODE */
  109. namespace boost {
  110. namespace contract {
  111. class virtual_;
  112. template<typename VR = void>
  113. class specify_precondition_old_postcondition_except;
  114. }
  115. }
  116. #endif // #include guard