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