File indexing completed on 2025-01-18 09:30:26
0001
0002 #ifndef BOOST_CONTRACT_DETAIL_CONSTRUCTOR_HPP_
0003 #define BOOST_CONTRACT_DETAIL_CONSTRUCTOR_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 constructor : public cond_inv< none, C> {
0033 public:
0034 explicit constructor(C* obj) : cond_inv< none, C>(
0035 boost::contract::from_constructor, 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 this->check_entry_static_inv();
0051
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 ~constructor() 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 if(uncaught_exception()) {
0075 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
0076 this->check_exit_static_inv();
0077 #endif
0078 #ifndef BOOST_CONTRACT_NO_EXCEPTS
0079 this->check_except();
0080 #endif
0081 } else {
0082 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
0083 this->check_exit_all_inv();
0084 #endif
0085 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
0086 this->check_post(none());
0087 #endif
0088 }
0089 }
0090 #endif
0091 };
0092
0093 } } }
0094
0095 #endif
0096