• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #ifndef BOOST_CONTRACT_DETAIL_CHECK_HPP_
3 #define BOOST_CONTRACT_DETAIL_CHECK_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/config.hpp>
11 #ifndef BOOST_CONTRACT_NO_CHECKS
12     #include <boost/contract/core/exception.hpp>
13 
14     /* PRIVATE */
15 
16     #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
17         #include <boost/contract/detail/checking.hpp>
18         #include <boost/contract/detail/name.hpp>
19 
20         #define BOOST_CONTRACT_CHECK_IF_NOT_CHECKING_ALREADY_ \
21             if(!boost::contract::detail::checking::already())
22         #define BOOST_CONTRACT_CHECK_CHECKING_VAR_(guard) \
23             /* this name somewhat unique to min var shadow warnings */ \
24             boost::contract::detail::checking BOOST_CONTRACT_DETAIL_NAME2( \
25                     guard, __LINE__);
26     #else
27         #define BOOST_CONTRACT_CHECK_IF_NOT_CHECKING_ALREADY_ /* nothing */
28         #define BOOST_CONTRACT_CHECK_CHECKING_VAR_(guard) /* nothing */
29     #endif
30 
31     /* PUBLIC */
32 
33     #define BOOST_CONTRACT_DETAIL_CHECK(assertion) \
34         { \
35             try { \
36                 BOOST_CONTRACT_CHECK_IF_NOT_CHECKING_ALREADY_ \
37                 { \
38                     BOOST_CONTRACT_CHECK_CHECKING_VAR_(k) \
39                     { assertion; } \
40                 } \
41             } catch(...) { boost::contract::check_failure(); } \
42         }
43 #else
44     #define BOOST_CONTRACT_DETAIL_CHECK(assertion) {}
45 #endif
46 
47 #endif // #include guard
48 
49