]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/contract/detail/operation/constructor.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / contract / detail / operation / constructor.hpp
CommitLineData
11fdf7f2
TL
1
2#ifndef BOOST_CONTRACT_DETAIL_CONSTRUCTOR_HPP_
3#define BOOST_CONTRACT_DETAIL_CONSTRUCTOR_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#include <boost/contract/core/exception.hpp>
11#include <boost/contract/core/config.hpp>
12#include <boost/contract/detail/condition/cond_inv.hpp>
13#include <boost/contract/detail/none.hpp>
92f5a8d4 14#include <boost/contract/detail/exception.hpp>
11fdf7f2
TL
15#if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \
16 !defined(BOOST_CONTRACT_NO_INVARIANTS) || \
17 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
18 !defined(BOOST_CONTRACT_NO_EXCEPTS))
19 #include <boost/contract/detail/checking.hpp>
20#endif
21#if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \
22 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
23 !defined(BOOST_CONTRACT_NO_EXCEPTS)
24 #include <boost/config.hpp>
25 #include <exception>
26#endif
27
28namespace boost { namespace contract { namespace detail {
29
30// Ctor subcontracting impl via C++ obj construction mechanism.
31template<class C> // Non-copyable base.
32class constructor : public cond_inv</* VR = */ none, C> {
33public:
34 explicit constructor(C* obj) : cond_inv</* VR = */ none, C>(
35 boost::contract::from_constructor, obj) {}
36
37private:
38 #if !defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) || \
39 !defined(BOOST_CONTRACT_NO_OLDS)
40 void init() /* override */ {
41 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
42 if(checking::already()) return;
43 #endif
44
45 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
46 {
47 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
48 checking k;
49 #endif
50 this->check_entry_static_inv();
51 // No object before ctor body so check only static inv at
52 // entry. Ctor pre checked by constructor_precondition.
53 }
54 #endif
55 #ifndef BOOST_CONTRACT_NO_OLDS
56 this->copy_old();
57 #endif
58 }
59 #endif
60
61public:
62 #if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \
63 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
64 !defined(BOOST_CONTRACT_NO_EXCEPTS)
65 ~constructor() BOOST_NOEXCEPT_IF(false) {
66 this->assert_initialized();
67 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
68 if(checking::already()) return;
69 checking k;
70 #endif
71
72 // If ctor body threw, no obj so check only static inv. Otherwise,
73 // obj constructed so check static inv, non-static inv, and post.
92f5a8d4 74 if(uncaught_exception()) {
11fdf7f2
TL
75 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
76 this->check_exit_static_inv();
77 #endif
78 #ifndef BOOST_CONTRACT_NO_EXCEPTS
79 this->check_except();
80 #endif
81 } else {
82 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
83 this->check_exit_all_inv();
84 #endif
85 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
86 this->check_post(none());
87 #endif
88 }
89 }
90 #endif
91};
92
93} } } // namespace
94
95#endif // #include guard
96