123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- #ifndef BOOST_CONTRACT_OVERRIDE_HPP_
- #define BOOST_CONTRACT_OVERRIDE_HPP_
- #include <boost/contract/core/config.hpp>
- #include <boost/preprocessor/cat.hpp>
- #include <boost/preprocessor/config/config.hpp>
- #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
-
- #define BOOST_CONTRACT_NAMED_OVERRIDE(type_name, func_name)
- #elif !defined(BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS)
- #include <boost/contract/core/virtual.hpp>
- #include <boost/contract/detail/type_traits/mirror.hpp>
- #include <boost/contract/detail/tvariadic.hpp>
- #include <boost/contract/detail/none.hpp>
- #include <boost/contract/detail/name.hpp>
-
- #define BOOST_CONTRACT_OVERRIDE_CALL_BASE_(z, arity, arity_compl, \
- func_name) \
- template< \
- class BOOST_CONTRACT_DETAIL_NAME1(B), \
- class BOOST_CONTRACT_DETAIL_NAME1(C) \
- BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \
- BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(z, arity, \
- BOOST_CONTRACT_DETAIL_NAME1(Args)) \
- > \
- static void BOOST_CONTRACT_DETAIL_NAME1(call_base)( \
- boost::contract::virtual_* BOOST_CONTRACT_DETAIL_NAME1(v), \
- BOOST_CONTRACT_DETAIL_NAME1(C)* BOOST_CONTRACT_DETAIL_NAME1(obj) \
- BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \
- BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z(z, arity, \
- BOOST_CONTRACT_DETAIL_NAME1(Args), \
- &, \
- BOOST_CONTRACT_DETAIL_NAME1(args) \
- ) \
- BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA(arity_compl) \
- BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(z, arity_compl, \
- boost::contract::detail::none&) \
- ) { \
- BOOST_CONTRACT_DETAIL_NAME1(obj)-> \
- BOOST_CONTRACT_DETAIL_NAME1(B)::func_name( \
- BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(z, arity, \
- BOOST_CONTRACT_DETAIL_NAME1(args)) \
- BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \
- BOOST_CONTRACT_DETAIL_NAME1(v) \
- ); \
- }
- #if BOOST_CONTRACT_DETAIL_TVARIADIC
- #define BOOST_CONTRACT_OVERRIDE_CALL_BASE_DECL_(func_name) \
- BOOST_CONTRACT_OVERRIDE_CALL_BASE_(1, ~, ~, func_name)
- #else
- #include <boost/preprocessor/repetition/repeat.hpp>
- #include <boost/preprocessor/arithmetic/inc.hpp>
- #include <boost/preprocessor/arithmetic/sub.hpp>
- #define BOOST_CONTRACT_OVERRIDE_CALL_BASE_DECL_(func_name) \
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_CONTRACT_MAX_ARGS), \
- BOOST_CONTRACT_OVERRIDE_CALL_BASE_ARITY_, func_name) \
-
- #define BOOST_CONTRACT_OVERRIDE_CALL_BASE_ARITY_(z, arity, func_name) \
- BOOST_CONTRACT_OVERRIDE_CALL_BASE_(z, arity, \
- BOOST_PP_SUB(BOOST_CONTRACT_MAX_ARGS, arity), func_name)
- #endif
-
- #define BOOST_CONTRACT_NAMED_OVERRIDE(type_name, func_name) \
- struct type_name { \
- BOOST_CONTRACT_DETAIL_MIRROR_HAS_MEMBER_FUNCTION( \
- BOOST_CONTRACT_DETAIL_NAME1(has_member_function), \
- func_name \
- ) \
- BOOST_CONTRACT_OVERRIDE_CALL_BASE_DECL_(func_name) \
- };
- #else
- #define BOOST_CONTRACT_NAMED_OVERRIDE(type_name, func_name) \
- struct type_name {};
- #endif
-
- #define BOOST_CONTRACT_OVERRIDE(func_name) \
- BOOST_CONTRACT_NAMED_OVERRIDE(BOOST_PP_CAT(override_, func_name), func_name)
-
- #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
-
- #define BOOST_CONTRACT_OVERRIDES(...)
- #elif BOOST_PP_VARIADICS
- #include <boost/preprocessor/seq/for_each.hpp>
- #include <boost/preprocessor/variadic/to_seq.hpp>
-
-
- #define BOOST_CONTRACT_OVERRIDES_SEQ_(r, unused, func_name) \
- BOOST_CONTRACT_OVERRIDE(func_name)
-
-
- #define BOOST_CONTRACT_OVERRIDES(...) \
- BOOST_PP_SEQ_FOR_EACH(BOOST_CONTRACT_OVERRIDES_SEQ_, ~, \
- BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))
- #else
- #define BOOST_CONTRACT_OVERRIDES \
- BOOST_CONTRACT_ERROR_macro_OVERRIDES_requires_variadic_macros_otherwise_manually_repeat_OVERRIDE_macro
- #endif
- #endif
|