]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/contract/detail/operation/public_function.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / contract / detail / operation / public_function.hpp
1
2 #ifndef BOOST_CONTRACT_DETAIL_PUBLIC_FUNCTION_HPP_
3 #define BOOST_CONTRACT_DETAIL_PUBLIC_FUNCTION_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/virtual.hpp>
11 #include <boost/contract/core/exception.hpp>
12 #include <boost/contract/core/config.hpp>
13 #include <boost/contract/detail/condition/cond_subcontracting.hpp>
14 #include <boost/contract/detail/tvariadic.hpp>
15 #include <boost/contract/core/virtual.hpp>
16 #if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \
17 !defined(BOOST_CONTRACT_NO_INVARIANTS) || \
18 !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
19 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
20 !defined(BOOST_CONTRACT_NO_EXCEPTS))
21 #include <boost/contract/detail/checking.hpp>
22 #endif
23 #if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \
24 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
25 !defined(BOOST_CONTRACT_NO_EXCEPTS)
26 #include <boost/config.hpp>
27 #endif
28 #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
29 !defined(BOOST_CONTRACT_NO_EXCEPTS)
30 #include <exception>
31 #endif
32
33 namespace boost { namespace contract { namespace detail {
34
35 template<
36 class O, typename VR, typename F, class C
37 BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS)
38 BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(1, BOOST_CONTRACT_MAX_ARGS, Args)
39 >
40 class public_function : // Non-copyable base.
41 public cond_subcontracting<
42 O, VR, F, C
43 BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS)
44 BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(1, BOOST_CONTRACT_MAX_ARGS, Args)
45 >
46 {
47 public:
48 explicit public_function(
49 boost::contract::virtual_* v, C* obj, VR& r
50 BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS)
51 BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z(1,
52 BOOST_CONTRACT_MAX_ARGS, Args, &, args)
53 ) :
54 cond_subcontracting<
55 O, VR, F, C
56 BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS)
57 BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(1,
58 BOOST_CONTRACT_MAX_ARGS, Args)
59 >(
60 boost::contract::from_function, v, obj, r
61 BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS)
62 BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(1,
63 BOOST_CONTRACT_MAX_ARGS, args)
64 )
65 {}
66
67 private:
68 #if !defined(BOOST_CONTRACT_NO_INVARIANTS) || \
69 !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
70 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
71 !defined(BOOST_CONTRACT_NO_EXCEPTS)
72 void init() /* override */ {
73 #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
74 !defined(BOOST_CONTRACT_NO_EXCEPTS)
75 this->init_subcontracted_old();
76 #endif
77 if(!this->base_call()) {
78 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
79 if(checking::already()) return;
80 #endif
81 { // Acquire checking guard.
82 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
83 checking k;
84 #endif
85 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
86 this->check_subcontracted_entry_inv();
87 #endif
88 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
89 #ifndef \
90 BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION
91 this->check_subcontracted_pre();
92 } // Release checking guard (after pre check).
93 #else
94 } // Release checking guard (before pre check).
95 this->check_subcontracted_pre();
96 #endif
97 #else
98 } // Release checking guard.
99 #endif
100 #ifndef BOOST_CONTRACT_NO_OLDS
101 this->copy_subcontracted_old();
102 #endif
103 } else {
104 #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS
105 this->check_subcontracted_entry_inv();
106 #endif
107 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
108 this->check_subcontracted_pre();
109 #endif
110 #ifndef BOOST_CONTRACT_NO_OLDS
111 this->copy_subcontracted_old();
112 #endif
113 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
114 this->check_subcontracted_exit_inv();
115 #endif
116 if(std::uncaught_exception()) {
117 #ifndef BOOST_CONTRACT_NO_EXCEPTS
118 this->check_subcontracted_except();
119 #endif
120 } else {
121 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
122 this->check_subcontracted_post();
123 #endif
124 }
125 }
126 }
127 #endif
128
129 public:
130 #if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \
131 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
132 !defined(BOOST_CONTRACT_NO_EXCEPTS)
133 ~public_function() BOOST_NOEXCEPT_IF(false) {
134 this->assert_initialized();
135 if(!this->base_call()) {
136 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
137 if(checking::already()) return;
138 checking k;
139 #endif
140
141 #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS
142 this->check_subcontracted_exit_inv();
143 #endif
144 if(std::uncaught_exception()) {
145 #ifndef BOOST_CONTRACT_NO_EXCEPTS
146 this->check_subcontracted_except();
147 #endif
148 } else {
149 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
150 this->check_subcontracted_post();
151 #endif
152 }
153 }
154 }
155 #endif
156 };
157
158 } } } // namespace
159
160 #endif // #include guard
161