File indexing completed on 2025-01-18 09:30:26
0001
0002 #ifndef BOOST_CONTRACT_DETAIL_DESTRUCTOR_HPP_
0003 #define BOOST_CONTRACT_DETAIL_DESTRUCTOR_HPP_
0004
0005
0006
0007
0008
0009
0010 #include <boost/contract/core/exception.hpp>
0011 #include <boost/contract/core/config.hpp>
0012 #include <boost/contract/detail/condition/cond_inv.hpp>
0013 #include <boost/contract/detail/none.hpp>
0014 #include <boost/contract/detail/exception.hpp>
0015 #if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \
0016 !defined(BOOST_CONTRACT_NO_INVARIANTS) || \
0017 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
0018 !defined(BOOST_CONTRACT_NO_EXCEPTS))
0019 #include <boost/contract/detail/checking.hpp>
0020 #endif
0021 #if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \
0022 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
0023 !defined(BOOST_CONTRACT_NO_EXCEPTS)
0024 #include <boost/config.hpp>
0025 #include <exception>
0026 #endif
0027
0028 namespace boost { namespace contract { namespace detail {
0029
0030
0031 template<class C>
0032 class destructor : public cond_inv< none, C> {
0033 public:
0034 explicit destructor(C* obj) : cond_inv< none, C>(
0035 boost::contract::from_destructor, obj) {}
0036
0037 private:
0038 #if !defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) || \
0039 !defined(BOOST_CONTRACT_NO_OLDS)
0040 void init() {
0041 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
0042 if(checking::already()) return;
0043 #endif
0044
0045 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
0046 {
0047 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
0048 checking k;
0049 #endif
0050
0051 this->check_entry_all_inv();
0052
0053 }
0054 #endif
0055 #ifndef BOOST_CONTRACT_NO_OLDS
0056 this->copy_old();
0057 #endif
0058 }
0059 #endif
0060
0061 public:
0062 #if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \
0063 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
0064 !defined(BOOST_CONTRACT_NO_EXCEPTS)
0065 ~destructor() BOOST_NOEXCEPT_IF(false) {
0066 this->assert_initialized();
0067 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
0068 if(checking::already()) return;
0069 checking k;
0070 #endif
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 if(uncaught_exception()) {
0082 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
0083 this->check_exit_all_inv();
0084 #endif
0085 #ifndef BOOST_CONTRACT_NO_EXCEPTS
0086 this->check_except();
0087 #endif
0088 } else {
0089 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
0090 this->check_exit_static_inv();
0091 #endif
0092 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
0093 this->check_post(none());
0094 #endif
0095 }
0096 }
0097 #endif
0098 };
0099
0100 } } }
0101
0102 #endif
0103