2 #ifndef BOOST_CONTRACT_DETAIL_FUNCTION_HPP_
3 #define BOOST_CONTRACT_DETAIL_FUNCTION_HPP_
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
10 #include <boost/contract/core/exception.hpp>
11 #include <boost/contract/core/config.hpp>
12 #include <boost/contract/detail/condition/cond_post.hpp>
13 #if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \
14 !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
15 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
16 !defined(BOOST_CONTRACT_NO_EXCEPTS))
17 #include <boost/contract/detail/checking.hpp>
19 #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
20 !defined(BOOST_CONTRACT_NO_EXCEPTS)
21 #include <boost/config.hpp>
25 namespace boost { namespace contract { namespace detail {
27 // Used for free function, private and protected member functions.
28 class function : public cond_post</* VR = */ none> { // Non-copyable base.
30 explicit function() : cond_post</* VR = */ none>(
31 boost::contract::from_function) {}
34 #if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
35 !defined(BOOST_CONTRACT_NO_OLDS)
36 void init() /* override */ {
37 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
38 if(checking::already()) return;
40 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
42 #if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && \
44 BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION)
50 #ifndef BOOST_CONTRACT_NO_OLDS
57 #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
58 !defined(BOOST_CONTRACT_NO_EXCEPTS)
59 ~function() BOOST_NOEXCEPT_IF(false) {
60 this->assert_initialized();
61 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
62 if(checking::already()) return;
66 if(std::uncaught_exception()) {
67 #ifndef BOOST_CONTRACT_NO_EXCEPTS
71 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
72 this->check_post(none());
81 #endif // #include guard