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 #include <boost/contract/detail/exception.hpp>
14 #if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \
15 !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
16 !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
17 !defined(BOOST_CONTRACT_NO_EXCEPTS))
18 #include <boost/contract/detail/checking.hpp>
20 #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
21 !defined(BOOST_CONTRACT_NO_EXCEPTS)
22 #include <boost/config.hpp>
26 namespace boost { namespace contract { namespace detail {
28 // Used for free function, private and protected member functions.
29 class function : public cond_post</* VR = */ none> { // Non-copyable base.
31 explicit function() : cond_post</* VR = */ none>(
32 boost::contract::from_function) {}
35 #if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
36 !defined(BOOST_CONTRACT_NO_OLDS)
37 void init() /* override */ {
38 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
39 if(checking::already()) return;
41 #ifndef BOOST_CONTRACT_NO_PRECONDITIONS
43 #if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && \
45 BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION)
51 #ifndef BOOST_CONTRACT_NO_OLDS
58 #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
59 !defined(BOOST_CONTRACT_NO_EXCEPTS)
60 ~function() BOOST_NOEXCEPT_IF(false) {
61 this->assert_initialized();
62 #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
63 if(checking::already()) return;
67 if(uncaught_exception()) {
68 #ifndef BOOST_CONTRACT_NO_EXCEPTS
72 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
73 this->check_post(none());
82 #endif // #include guard