Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:26

0001 
0002 #ifndef BOOST_CONTRACT_DETAIL_PUBLIC_FUNCTION_HPP_
0003 #define BOOST_CONTRACT_DETAIL_PUBLIC_FUNCTION_HPP_
0004 
0005 // Copyright (C) 2008-2018 Lorenzo Caminiti
0006 // Distributed under the Boost Software License, Version 1.0 (see accompanying
0007 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
0008 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
0009 
0010 #include <boost/contract/core/virtual.hpp>
0011 #include <boost/contract/core/exception.hpp>
0012 #include <boost/contract/core/config.hpp>
0013 #include <boost/contract/core/virtual.hpp>
0014 #include <boost/contract/detail/condition/cond_subcontracting.hpp>
0015 #include <boost/contract/detail/tvariadic.hpp>
0016 #include <boost/contract/detail/exception.hpp>
0017 #if     !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \
0018         !defined(BOOST_CONTRACT_NO_INVARIANTS) || \
0019         !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
0020         !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
0021         !defined(BOOST_CONTRACT_NO_EXCEPTS))
0022     #include <boost/contract/detail/checking.hpp>
0023 #endif
0024 #if     !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \
0025         !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
0026         !defined(BOOST_CONTRACT_NO_EXCEPTS)
0027     #include <boost/config.hpp>
0028 #endif
0029 #if     !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
0030         !defined(BOOST_CONTRACT_NO_EXCEPTS)
0031     #include <exception>
0032 #endif
0033 
0034 namespace boost { namespace contract { namespace detail {
0035 
0036 template<
0037     class O, typename VR, typename F, class C
0038     BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS)
0039     BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(1, BOOST_CONTRACT_MAX_ARGS, Args)
0040 >
0041 class public_function : // Non-copyable base.
0042     public cond_subcontracting<
0043         O, VR, F, C
0044         BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS)
0045         BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(1, BOOST_CONTRACT_MAX_ARGS, Args)
0046     >
0047 {
0048 public:
0049     explicit public_function(
0050         boost::contract::virtual_* v, C* obj, VR& r
0051         BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS)
0052         BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z(1,
0053                 BOOST_CONTRACT_MAX_ARGS, Args, &, args)
0054     ) :
0055         cond_subcontracting<
0056             O, VR, F, C
0057             BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS)
0058             BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(1,
0059                     BOOST_CONTRACT_MAX_ARGS, Args)
0060         >(
0061             boost::contract::from_function, v, obj, r
0062             BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS)
0063             BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(1,
0064                     BOOST_CONTRACT_MAX_ARGS, args)
0065         )
0066     {}
0067 
0068 private:
0069     #if     !defined(BOOST_CONTRACT_NO_INVARIANTS) || \
0070             !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
0071             !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
0072             !defined(BOOST_CONTRACT_NO_EXCEPTS)
0073         void init() /* override */ {
0074             #if     !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
0075                     !defined(BOOST_CONTRACT_NO_EXCEPTS)
0076                 this->init_subcontracted_old();
0077             #endif
0078             if(!this->base_call()) {
0079                 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
0080                     if(checking::already()) return;
0081                 #endif
0082                 { // Acquire checking guard.
0083                     #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
0084                         checking k;
0085                     #endif
0086                     #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
0087                         this->check_subcontracted_entry_inv();
0088                     #endif
0089                     #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
0090                         #ifndef \
0091   BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION
0092                             this->check_subcontracted_pre();
0093                             } // Release checking guard (after pre check).
0094                         #else
0095                             } // Release checking guard (before pre check).
0096                             this->check_subcontracted_pre();
0097                         #endif
0098                     #else
0099                         } // Release checking guard.
0100                     #endif
0101                 #ifndef BOOST_CONTRACT_NO_OLDS
0102                     this->copy_subcontracted_old();
0103                 #endif
0104             } else {
0105                 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
0106                     this->check_subcontracted_entry_inv();
0107                 #endif
0108                 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
0109                     this->check_subcontracted_pre();
0110                 #endif
0111                 #ifndef BOOST_CONTRACT_NO_OLDS
0112                     this->copy_subcontracted_old();
0113                 #endif
0114                 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
0115                     this->check_subcontracted_exit_inv();
0116                 #endif
0117                 if(uncaught_exception()) {
0118                     #ifndef BOOST_CONTRACT_NO_EXCEPTS
0119                         this->check_subcontracted_except();
0120                     #endif
0121                 } else {
0122                     #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
0123                         this->check_subcontracted_post();
0124                     #endif
0125                 }
0126             }
0127         }
0128     #endif
0129 
0130 public:
0131     #if     !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \
0132             !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
0133             !defined(BOOST_CONTRACT_NO_EXCEPTS)
0134         ~public_function() BOOST_NOEXCEPT_IF(false) {
0135             this->assert_initialized();
0136             if(!this->base_call()) {
0137                 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
0138                     if(checking::already()) return;
0139                     checking k;
0140                 #endif
0141 
0142                 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
0143                     this->check_subcontracted_exit_inv();
0144                 #endif
0145                 if(uncaught_exception()) {
0146                     #ifndef BOOST_CONTRACT_NO_EXCEPTS
0147                         this->check_subcontracted_except();
0148                     #endif
0149                 } else {
0150                     #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
0151                         this->check_subcontracted_post();
0152                     #endif
0153                 }
0154             }
0155         }
0156     #endif
0157 };
0158 
0159 } } } // namespace
0160 
0161 #endif // #include guard
0162