config.hpp 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. #ifndef BOOST_CONTRACT_CONFIG_HPP_
  2. #define BOOST_CONTRACT_CONFIG_HPP_
  3. // Copyright (C) 2008-2018 Lorenzo Caminiti
  4. // Distributed under the Boost Software License, Version 1.0 (see accompanying
  5. // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
  6. // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
  7. /** @file
  8. Configure this library compile-time and run-time behaviours.
  9. */
  10. // IMPORTANT: This header MUST NOT #include any other header of this lib.
  11. // That way users can #include this header and not #include any of this lib
  12. // headers after that depending on the contract 0/1 macros below ensuring no
  13. // compilation overhead.
  14. // Export symbols when compiling as shared lib (for internal use only). (Named
  15. // after similar macros in all Boost libs.)
  16. // BOOST_CONTRACT_SOURCE
  17. // Disable automatic library selection for linking. (Named after similar macros
  18. // in all Boost libs.)
  19. // BOOST_CONTRACT_NO_LIB
  20. // BOOST_ALL_NO_LIB
  21. #if (!defined(BOOST_CONTRACT_DYN_LINK) && defined(BOOST_ALL_DYN_LINK)) || \
  22. defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
  23. /**
  24. Define this macro to compile this library as a shared library (recommended).
  25. If this macro is defined, this library is compiled so it can be linked
  26. as a shared library (a.k.a., Dynamically Linked Library or DLL) to user
  27. code.
  28. This library will automatically define this macro when Boost libraries are
  29. built as shared libraries (e.g., defining @c BOOST_ALL_DYN_LINK or using
  30. <c>bjam link=shared ...</c>).
  31. @warning In general this library will correctly check contracts at
  32. run-time only when compiled as a shared library, unless user
  33. code checks contracts in a single program unit (e.g., a single
  34. program with only statically linked libraries).
  35. Therefore, it is recommended to build and use this library as
  36. a shared library by defining this macro (or equivalently by
  37. building all Boost libraries as shared libraries).
  38. @see @RefSect{getting_started, Getting Started}
  39. */
  40. #define BOOST_CONTRACT_DYN_LINK
  41. #elif defined(BOOST_CONTRACT_DYN_LINK) && defined(BOOST_CONTRACT_STATIC_LINK)
  42. #error "DYN_LINK defined with STATIC_LINK"
  43. #endif
  44. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  45. /**
  46. Define this macro to compile this library as a static library (not
  47. recommended).
  48. If this macro is defined, this library is compiled so it can be linked
  49. statically to user code.
  50. This library will automatically define this macro when Boost libraries
  51. are built as static libraries.
  52. @warning This library is not guaranteed to always work correctly at
  53. run-time when this macro is defined (define
  54. @RefMacro{BOOST_CONTRACT_DYN_LINK} or @c BOOST_ALL_DYN_LINK
  55. instead).
  56. However, this macro can be defined and this library can be
  57. safely used as a static library for user code that checks
  58. contracts in a single program unit (e.g., a single program with
  59. only statically linked libraries).
  60. @see @RefSect{getting_started, Getting Started}
  61. */
  62. #define BOOST_CONTRACT_STATIC_LINK
  63. #elif defined(BOOST_CONTRACT_STATIC_LINK) && defined(BOOST_CONTRACT_DYN_LINK)
  64. #error "STATIC_LINK defined with DYN_LINK"
  65. #endif
  66. #ifdef BOOST_CONTRACT_HEADER_ONLY
  67. #error "leave DYN_LINK and STATIC_LINK undefined instead"
  68. #elif (!defined(BOOST_CONTRACT_DYN_LINK) && \
  69. !defined(BOOST_CONTRACT_STATIC_LINK)) || \
  70. defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
  71. /**
  72. Automatically defined by this library when it is being used as a header-only
  73. library (not recommended).
  74. This macro is not a configuration macro and this library will generate a
  75. compile-time error if users try to define it directly.
  76. This library will automatically define this macro when users do not define
  77. @RefMacro{BOOST_CONTRACT_DYN_LINK} (or @c BOOST_ALL_DYN_LINK) and
  78. @RefMacro{BOOST_CONTRACT_STATIC_LINK}.
  79. When used as a header-only library, this library code does not have to be
  80. compiled separately from user code, this library headers are simply included
  81. and compiled as part of the user program.
  82. @warning This library is not guaranteed to always work correctly at
  83. run-time when this macro is defined (define
  84. @RefMacro{BOOST_CONTRACT_DYN_LINK} or @c BOOST_ALL_DYN_LINK
  85. instead).
  86. However, this macro can be defined and this library can be
  87. safely used as a header-only library for user code that checks
  88. contracts in a single program unit (e.g., a single program with
  89. only statically linked libraries).
  90. @see @RefSect{getting_started, Getting Started}
  91. */
  92. #define BOOST_CONTRACT_HEADER_ONLY
  93. #endif
  94. #if (!defined(BOOST_CONTRACT_DISABLE_THREADS) && \
  95. defined(BOOST_DISABLE_THREADS)) || \
  96. defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
  97. /**
  98. Define this macro to not lock internal library data for thread safety
  99. (undefined by default).
  100. Defining this macro will make the library implementation code not thread
  101. safe so this macro should not be defined unless the library is being used by
  102. single-threaded applications only.
  103. This library will automatically define this macro when Boost libraries are
  104. built without threads (e.g., defining @c BOOST_DISABLE_THREADS).
  105. @note When this macro is left undefined this library needs to internally
  106. use some sort of global lock (to ensure contract checking is
  107. globally disabled when other contracts are being checked and also to
  108. safely access failure handler functors).
  109. That could introduce an undesired amount of synchronization in some
  110. multi-threaded applications.
  111. @see @RefSect{contract_programming_overview.assertions, Assertions}
  112. */
  113. #define BOOST_CONTRACT_DISABLE_THREADS
  114. #endif
  115. #ifndef BOOST_CONTRACT_MAX_ARGS
  116. /**
  117. Maximum number of arguments for public function overrides on compilers that
  118. do not support variadic templates (default to @c 10).
  119. On compilers that do not support C++11 variadic templates, this macro is
  120. defined to the maximum number of arguments that public function overrides
  121. can have and pass to @RefFunc{boost::contract::public_function} (users can
  122. redefine this macro to a different value).
  123. On compilers that support variadic templates, this macro has no effect.
  124. @note Regardless of the value of this macro and of compiler support for
  125. variadic templates, there might be an intrinsic limit of about 18
  126. arguments for public function overrides (because of similar limits
  127. in Boost.MPL and Boost.FunctionTypes internally used by this
  128. library).
  129. @see @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros}
  130. */
  131. #define BOOST_CONTRACT_MAX_ARGS 10
  132. #endif
  133. #ifndef BOOST_CONTRACT_BASES_TYPEDEF
  134. /**
  135. Define the name of the base type @c typedef (@c base_types by default).
  136. This macro expands to the name of the @c typedef that lists the base
  137. classes for subcontracting via @RefMacro{BOOST_CONTRACT_BASE_TYPES}:
  138. @code
  139. class u
  140. #define BASES public b, private w
  141. : BASES
  142. {
  143. friend class boost::contract:access;
  144. typedef BOOST_CONTRACT_BASE_TYPES(BASES) BOOST_CONTRACT_TYPEDEF;
  145. #undef BASES
  146. ...
  147. };
  148. @endcode
  149. When used this way, users can redefine this macro if the @c typedef must
  150. have a name different from @c base_types (because of name clashes in user
  151. code, etc.).
  152. @see @RefSect{tutorial.base_classes__subcontracting_, Base Classes}
  153. */
  154. #define BOOST_CONTRACT_BASES_TYPEDEF base_types
  155. #endif
  156. #ifndef BOOST_CONTRACT_INVARIANT_FUNC
  157. /**
  158. Define the name of the class invariant member function (@c invariant by
  159. default).
  160. This macro expands to the name of the @c const and <c>const volatile</c>
  161. member functions that check class invariants and volatile class invariants
  162. respectively:
  163. @code
  164. class u {
  165. friend class boost::contract::access;
  166. void BOOST_CONTRACT_INVARIANT_FUNC() const {
  167. BOOST_CONTRACT_ASSERT(...);
  168. ...
  169. }
  170. void BOOST_CONTRACT_INVARIANT_FUNC() const volatile {
  171. BOOST_CONTRACT_ASSERT(...);
  172. ...
  173. }
  174. ...
  175. };
  176. @endcode
  177. When used this way, users can redefine this macro if the invariant functions
  178. must have a name different from @c invariant (because of name clashes in
  179. user code, etc.).
  180. @note C++ does not allow to overload member functions based on the
  181. @c static classifier, so this macro must always be defined to be
  182. different than the function name defined for
  183. @RefMacro{BOOST_CONTRACT_STATIC_INVARIANT_FUNC}.
  184. @see @RefSect{tutorial.class_invariants, Class Invariants},
  185. @RefSect{extras.volatile_public_functions,
  186. Volatile Public Functions}
  187. */
  188. #define BOOST_CONTRACT_INVARIANT_FUNC invariant
  189. #endif
  190. #ifndef BOOST_CONTRACT_STATIC_INVARIANT_FUNC
  191. /**
  192. Define the name of the static invariant member function (@c static_invariant
  193. by default).
  194. This macro expands to the name of the @c static member function that checks
  195. static class invariants:
  196. @code
  197. class u {
  198. friend class boost::contract::access;
  199. static void BOOST_CONTRACT_STATIC_INVARIANT_FUNC() {
  200. BOOST_CONTRACT_ASSERT(...);
  201. ...
  202. }
  203. ...
  204. };
  205. @endcode
  206. When used this way, users can redefine this macro if the static invariant
  207. function must have a name different from @c static_invariant (because of
  208. name clashes in user code, etc.).
  209. @note C++ does not allow to overload member functions based on the
  210. @c static classifier, so this macro must always be defined to be
  211. different than the function name defined for
  212. @RefMacro{BOOST_CONTRACT_INVARIANT_FUNC}.
  213. @see @RefSect{tutorial.class_invariants, Class Invariants}
  214. */
  215. #define BOOST_CONTRACT_STATIC_INVARIANT_FUNC static_invariant
  216. #endif
  217. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  218. /**
  219. Disable some compile-time errors generated by this library (undefined by
  220. default).
  221. Defining this macro disables a number of static checks and related
  222. compile-time errors generated by this library, for example:
  223. @li The static invariant member function named as
  224. @c BOOST_CONTRACT_STATIC_INVARIANT_FUNC must be declared @c static.
  225. @li Non-static invariant member functions named as
  226. @c BOOST_CONTRACT_INVARIANT_FUNC must be declared either @c const,
  227. <c>const volatile</c>, or <c>volatile const</c>.
  228. @li Derived classes that program contracts for one or more public function
  229. overrides via @RefFunc{boost::contract::public_function} must also
  230. define the @RefMacro{BOOST_CONTRACT_BASE_TYPES} @c typedef.
  231. In general, it is not recommended to define this macro because these
  232. compile-time checks can guard against misuses of this library.
  233. @see @RefSect{tutorial.class_invariants, Class Invariants},
  234. @RefSect{tutorial.base_classes__subcontracting_, Base Classes}
  235. */
  236. #define BOOST_CONTRACT_PERMISSIVE
  237. #endif
  238. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  239. /**
  240. Code block to execute if contracts are not assigned to a
  241. @RefClass{boost::contract::check} variable (undefined and executes
  242. @c BOOST_ASSERT(false) by default).
  243. In general, there is a logic error in the program when contracts are not
  244. explicitly assigned to a local variable of type
  245. @RefClass{boost::contract::check} and without using C++11 @c auto
  246. declarations (because that is a misuse of this library).
  247. Therefore, by default (i.e., when this macro is not defined) this library
  248. calls <c>BOOST_ASSERT(false)</c> in those cases.
  249. If this macro is defined, this library will execute the code expanded by
  250. this macro instead of calling @c BOOST_ASSERT(false) (if programmers prefer
  251. to throw an exception, etc.).
  252. This macro can also be defined to be any block of code (and use empty curly
  253. brackets @c {} to generate no error, not recommended), for example (on GCC):
  254. @code
  255. gcc -DBOOST_CONTRACT_ON_MISSING_CHECK_DECL='{ throw std::logic_error("missing contract check declaration"); }' ...
  256. @endcode
  257. @see @RefSect{tutorial, Tutorial}
  258. */
  259. #define BOOST_CONTRACT_ON_MISSING_CHECK_DECL
  260. #endif
  261. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  262. /**
  263. Define this macro to not disable other assertions while checking
  264. preconditions (undefined by default).
  265. Not disabling other assertions while checking preconditions can lead to
  266. infinite recursion in user code so by default this macro is not defined.
  267. However, the @RefSect{bibliography, [N1962]} proposal does not disable
  268. assertions while checking preconditions because arguments can reach the
  269. function body unchecked if assertions are disabled while checking
  270. preconditions (e.g., when these same functions bodies are called to check
  271. the preconditions in question).
  272. This macro can be defined to obtain the behaviour specified in
  273. @RefSect{bibliography, [N1962]} (at the risk of infinite recursion).
  274. @see @RefSect{contract_programming_overview.feature_summary,
  275. Feature Summary}
  276. */
  277. #define BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION
  278. #endif
  279. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  280. /**
  281. Define this macro to not disable any assertion while checking other
  282. assertions (undefined by default).
  283. Not disabling assertions while checking other assertions can lead to
  284. infinite recursion in user code so by default this macro is not defined.
  285. (Defining this macro automatically implies that other assertion checking is
  286. disabled while checking preconditions as if
  287. @RefMacro{BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION} was also
  288. defined.)
  289. @see @RefSect{contract_programming_overview.feature_summary,
  290. Feature Summary}
  291. */
  292. #define BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
  293. #endif
  294. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  295. /**
  296. Define this macro to evaluate and check audit assertions at run-time
  297. (undefined by default).
  298. Audit assertions and implementation checks programmed via
  299. @RefMacro{BOOST_CONTRACT_ASSERT_AUDIT} and
  300. @RefMacro{BOOST_CONTRACT_CHECK_AUDIT} are always compiled and validated
  301. syntactically.
  302. However, they are not evaluated and checked at run-time unless
  303. this macro is defined (because these conditions can be computationally
  304. expensive, at least compared to the computational cost of executing the
  305. function body).
  306. @see @RefSect{extras.assertion_levels, Assertion Levels}
  307. */
  308. #define BOOST_CONTRACT_AUDITS
  309. #endif
  310. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  311. /**
  312. If defined, this library disables implementation checks (undefined by
  313. default).
  314. If this macro is defined, this library internal code is also optimized to
  315. reduce compile-time (not just run-time) overhead associated with
  316. implementation checks.
  317. In addition, users can manually program @c \#ifndef statements in their code
  318. using this macro to completely disable compilation of implementation checks
  319. or use @RefMacro{BOOST_CONTRACT_CHECK} (recommended).
  320. @see @RefSect{advanced.implementation_checks,
  321. Implementation Checks},
  322. @RefSect{extras.disable_contract_checking,
  323. Disable Contract Checking},
  324. @RefSect{extras.disable_contract_compilation__macro_interface_,
  325. Disable Contract Compilation}
  326. */
  327. #define BOOST_CONTRACT_NO_CHECKS
  328. #endif
  329. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  330. /**
  331. If defined, this library does not check preconditions (undefined by
  332. default).
  333. If this macro is defined, this library internal code is also optimized to
  334. reduce compile-time (not just run-time) overhead associated with
  335. checking preconditions.
  336. In addition, users can manually program @c \#ifndef statements in their code
  337. using this macro to completely disable compilation of preconditions or use
  338. the macros defined in @c boost/contract_macro.hpp (recommended only for
  339. applications where it is truly necessary to completely remove contract code
  340. compilation from production code).
  341. @see @RefSect{tutorial.preconditions, Preconditions},
  342. @RefSect{extras.disable_contract_checking,
  343. Disable Contract Checking},
  344. @RefSect{extras.disable_contract_compilation__macro_interface_,
  345. Disable Contract Compilation}
  346. */
  347. #define BOOST_CONTRACT_NO_PRECONDITIONS
  348. #endif
  349. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  350. /**
  351. If defined, this library does not check postconditions (undefined by
  352. default).
  353. If this macro is defined, this library internal code is also optimized to
  354. reduce compile-time (not just run-time) overhead associated with
  355. checking postconditions.
  356. In addition, users can manually program @c \#ifndef statements in their code
  357. using this macro to completely disable compilation of postconditions or use
  358. the macros defined in @c boost/contract_macro.hpp (recommended only for
  359. applications where it is truly necessary to completely remove contract code
  360. compilation from production code).
  361. It is necessary to disable both postconditions and exception guarantees
  362. defining @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and
  363. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} in order to disable old value copies
  364. (see @RefMacro{BOOST_CONTRACT_NO_OLDS}).
  365. @see @RefSect{tutorial.postconditions, Postconditions},
  366. @RefSect{extras.disable_contract_checking,
  367. Disable Contract Checking},
  368. @RefSect{extras.disable_contract_compilation__macro_interface_,
  369. Disable Contract Compilation}
  370. */
  371. #define BOOST_CONTRACT_NO_POSTCONDITIONS
  372. #endif
  373. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  374. /**
  375. If defined, this library does not check exception guarantees (undefined by
  376. default).
  377. If this macro is defined, this library internal code is also optimized to
  378. reduce compile-time (not just run-time) overhead associated with
  379. checking exception guarantees.
  380. In addition, users can manually program @c \#ifndef statements in their code
  381. using this macro to completely disable compilation of exception guarantees
  382. or use the macros defined in @c boost/contract_macro.hpp (recommended only
  383. for applications where it is truly necessary to completely remove contract
  384. code compilation from production code).
  385. It is necessary to disable both postconditions and exception guarantees
  386. defining @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and
  387. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} in order to disable old value copies
  388. (see @RefMacro{BOOST_CONTRACT_NO_OLDS}).
  389. @see @RefSect{tutorial.exception_guarantees, Exception Guarantees},
  390. @RefSect{extras.disable_contract_checking,
  391. Disable Contract Checking},
  392. @RefSect{extras.disable_contract_compilation__macro_interface_,
  393. Disable Contract Compilation}
  394. */
  395. #define BOOST_CONTRACT_NO_EXCEPTS
  396. #endif
  397. #if defined(BOOST_CONTRACT_DETAIL_DOXYGEN) || \
  398. ( \
  399. !defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) && \
  400. defined(BOOST_CONTRACT_NO_INVARIANTS) \
  401. )
  402. /**
  403. If defined, this library does not check class invariants at entry (undefined
  404. by default).
  405. If this macro is defined, this library internal code is also optimized to
  406. reduce compile-time (not just run-time) overhead associated with
  407. checking class invariants at entry.
  408. In addition, users can manually program @c \#ifndef statements in their code
  409. using this macro to completely disable compilation of entry class invariants
  410. or use the macros defined in @c boost/contract_macro.hpp (recommended only
  411. for applications where it is truly necessary to completely remove contract
  412. code compilation from production code).
  413. This macro is automatically defined when
  414. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined.
  415. @see @RefSect{tutorial.class_invariants, Class Invariants},
  416. @RefSect{extras.disable_contract_checking,
  417. Disable Contract Checking},
  418. @RefSect{extras.disable_contract_compilation__macro_interface_,
  419. Disable Contract Compilation}
  420. */
  421. #define BOOST_CONTRACT_NO_ENTRY_INVARIANTS
  422. #endif
  423. #if defined(BOOST_CONTRACT_DETAIL_DOXYGEN) || \
  424. ( \
  425. !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) && \
  426. defined(BOOST_CONTRACT_NO_INVARIANTS) \
  427. )
  428. /**
  429. If defined, this library does not check class invariants at exit (undefined
  430. by default).
  431. If this macro is defined, this library internal code is also optimized to
  432. reduce compile-time (not just run-time) overhead associated with
  433. checking class invariants at exit.
  434. In addition, users can manually program @c \#ifndef statements in their code
  435. using this macro to completely disable compilation of exit class invariants
  436. or use the macros defined in @c boost/contract_macro.hpp (recommended only
  437. for applications where it is truly necessary to completely remove contract
  438. code compilation from production code).
  439. This macro is automatically defined when
  440. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined.
  441. @see @RefSect{tutorial.class_invariants, Class Invariants},
  442. @RefSect{extras.disable_contract_checking,
  443. Disable Contract Checking},
  444. @RefSect{extras.disable_contract_compilation__macro_interface_,
  445. Disable Contract Compilation}
  446. */
  447. #define BOOST_CONTRACT_NO_EXIT_INVARIANTS
  448. #endif
  449. #if !defined(BOOST_CONTRACT_NO_INVARIANTS) && \
  450. defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) && \
  451. defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS)
  452. /**
  453. If defined, this library does not check class invariants (undefined by
  454. default).
  455. If this macro is defined, this library internal code is also optimized to
  456. reduce compile-time (not just run-time) overhead associated with
  457. checking class invariants.
  458. In addition, users can manually program @c \#ifndef statements in their code
  459. using this macro to completely disable compilation of class invariants or
  460. use the macros defined in @c boost/contract_macro.hpp (recommended only for
  461. applications where it is truly necessary to completely remove contract code
  462. compilation from production code).
  463. Defining this macro is equivalent to defining both
  464. @RefMacro{BOOST_CONTRACT_NO_ENTRY_INVARIANTS} and
  465. @RefMacro{BOOST_CONTRACT_NO_EXIT_INVARIANTS}.
  466. @see @RefSect{tutorial.class_invariants, Class Invariants},
  467. @RefSect{extras.disable_contract_checking,
  468. Disable Contract Checking},
  469. @RefSect{extras.disable_contract_compilation__macro_interface_,
  470. Disable Contract Compilation}
  471. */
  472. #define BOOST_CONTRACT_NO_INVARIANTS
  473. #endif
  474. #ifdef BOOST_CONTRACT_NO_OLDS
  475. #error "define NO_POSTCONDITIONS and NO_EXCEPTS instead"
  476. #elif defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \
  477. defined(BOOST_CONTRACT_NO_EXCEPTS)
  478. /**
  479. Automatically defined by this library when old value copies are not to be
  480. performed.
  481. This macro is not a configuration macro and this library will generate a
  482. compile-time error if users try to define it directly.
  483. This library will automatically define this macro when users define both
  484. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and
  485. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}.
  486. Users can manually program @c \#ifndef statements in their code using this
  487. macro to completely disable compilation of old value copies or use the
  488. macros defined in @c boost/contract_macro.hpp (recommended only for
  489. applications where it is truly necessary to completely remove contract code
  490. compilation from production code).
  491. @see @RefSect{tutorial.old_values, Old Values},
  492. @RefSect{advanced.old_values_copied_at_body,
  493. Old Values Copied at Body},
  494. @RefSect{extras.disable_contract_compilation__macro_interface_,
  495. Disable Contract Compilation}
  496. */
  497. #define BOOST_CONTRACT_NO_OLDS
  498. #endif
  499. // Ctor pre checked separately and outside RAII so not part of this #define.
  500. #ifdef BOOST_CONTRACT_NO_CONSTRUCTORS
  501. #error "define NO_INVARIANTS, NO_POSTCONDITIONS, and NO_EXCEPTS instead"
  502. #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \
  503. defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \
  504. defined(BOOST_CONTRACT_NO_EXCEPTS)
  505. /**
  506. Automatically defined by this library when contracts are not checked for
  507. constructors.
  508. This macro is not a configuration macro and this library will generate a
  509. compile-time error if users try to define it directly.
  510. This library will automatically define this macro when users define all
  511. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
  512. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
  513. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}.
  514. Users can manually program @c \#ifndef statements in their code using this
  515. macro to completely disable compilation of contracts for constructors or use
  516. the macros defined in @c boost/contract_macro.hpp (recommended only for
  517. applications where it is truly necessary to completely remove contract code
  518. compilation from production code).
  519. @note Constructor preconditions are checked separately by
  520. @RefClass{boost::contract::constructor_precondition} so they are
  521. disabled by @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS} instead.
  522. @see @RefSect{tutorial.constructors, Constructors},
  523. @RefSect{extras.disable_contract_compilation__macro_interface_,
  524. Disable Contract Compilation}
  525. */
  526. #define BOOST_CONTRACT_NO_CONSTRUCTORS
  527. #endif
  528. #ifdef BOOST_CONTRACT_NO_DESTRUCTORS
  529. #error "define NO_INVARIANTS, NO_POSTCONDITIONS, and NO_EXCEPTS instead"
  530. #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \
  531. defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \
  532. defined(BOOST_CONTRACT_NO_EXCEPTS)
  533. /**
  534. Automatically defined by this library when contracts are not checked for
  535. destructors.
  536. This macro is not a configuration macro and this library will generate a
  537. compile-time error if users try to define it directly.
  538. This library will automatically define this macro when users define all
  539. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
  540. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
  541. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}.
  542. Users can manually program @c \#ifndef statements in their code using this
  543. macro to completely disable compilation of contracts for destructors or use
  544. the macros defined in @c boost/contract_macro.hpp (recommended only for
  545. applications where it is truly necessary to completely remove contract code
  546. compilation from production code).
  547. @see @RefSect{tutorial.destructors, Destructors},
  548. @RefSect{extras.disable_contract_compilation__macro_interface_,
  549. Disable Contract Compilation}
  550. */
  551. #define BOOST_CONTRACT_NO_DESTRUCTORS
  552. #endif
  553. #ifdef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
  554. #error "define NO_INVARIANTS, NO_PRECONDITIONS, NO_POSTCONDITIONS, and NO_EXCEPTS instead"
  555. #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \
  556. defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \
  557. defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \
  558. defined(BOOST_CONTRACT_NO_EXCEPTS)
  559. /**
  560. Automatically defined by this library when contracts are not checked for
  561. public functions.
  562. This macro is not a configuration macro and this library will generate a
  563. compile-time error if users try to define it directly.
  564. This library will automatically define this macro when users define all
  565. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
  566. @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
  567. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
  568. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}.
  569. Users can manually program @c \#ifndef statements in their code using this
  570. macro to completely disable compilation of contracts for public functions or
  571. use the macros defined in @c boost/contract_macro.hpp (recommended only for
  572. applications where it is truly necessary to completely remove contract code
  573. compilation from production code).
  574. @see @RefSect{tutorial.public_functions, Public Functions},
  575. @RefSect{extras.disable_contract_compilation__macro_interface_,
  576. Disable Contract Compilation}
  577. */
  578. #define BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS
  579. #endif
  580. #ifdef BOOST_CONTRACT_NO_FUNCTIONS
  581. #error "define NO_PRECONDITIONS, NO_POSTCONDITIONS, and NO_EXCEPTS instead"
  582. #elif defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \
  583. defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \
  584. defined(BOOST_CONTRACT_NO_EXCEPTS)
  585. /**
  586. Automatically defined by this library when contracts are not checked for
  587. non-member, private, or protected functions.
  588. This macro is not a configuration macro and this library will generate a
  589. compile-time error if users try to define it directly.
  590. This library will automatically define this macro when users define all
  591. @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
  592. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
  593. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}.
  594. Users can manually program @c \#ifndef statements in their code using this
  595. macro to completely disable compilation of contracts for non-member,
  596. private and protected functions, or use the macros defined in
  597. @c boost/contract_macro.hpp (recommended only for applications where it is
  598. truly necessary to completely remove contract code compilation from
  599. production code).
  600. This macro is also used when contracts are not checked for private or
  601. protected functions, lambda functions, code blocks, loops, etc.
  602. @see @RefSect{tutorial.non_member_functions, Non-Member Functions},
  603. @RefSect{advanced.private_and_protected_functions,
  604. Private and Protected Functions},
  605. @RefSect{advanced.lambdas__loops__code_blocks__and__constexpr__,
  606. Lambdas\, Loops\, Code Blocks},
  607. @RefSect{extras.disable_contract_compilation__macro_interface_,
  608. Disable Contract Compilation}
  609. */
  610. #define BOOST_CONTRACT_NO_FUNCTIONS
  611. #endif
  612. #ifdef BOOST_CONTRACT_NO_CONDITIONS
  613. #error "define NO_INVARIANTS, NO_PRECONDITIONS, NO_POSTCONDITIONS, and NO_EXCEPTS instead"
  614. #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \
  615. defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \
  616. defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \
  617. defined(BOOST_CONTRACT_NO_EXCEPTS)
  618. /**
  619. Automatically defined by this library when contracts are not checked for
  620. preconditions, postconditions, exceptions guarantees, and class invariants
  621. (excluding implementation checks).
  622. This macro is not a configuration macro and this library will generate a
  623. compile-time error if users try to define it directly.
  624. This library will automatically define this macro when users define all
  625. @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
  626. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS},
  627. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}, and
  628. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS}.
  629. Users can manually program @c \#ifndef statements in their code using this
  630. macro to completely disable compilation of contracts within specifications
  631. (so excluding implementation checks which are contracts within
  632. implementations instead), or use the macros defined in
  633. @c boost/contract_macro.hpp (recommended only for applications where it is
  634. truly necessary to completely remove contract code compilation from
  635. production code).
  636. @see @RefSect{extras.disable_contract_compilation__macro_interface_,
  637. Disable Contract Compilation}
  638. */
  639. #define BOOST_CONTRACT_NO_CONDITIONS
  640. #endif
  641. #ifdef BOOST_CONTRACT_NO_ALL
  642. #error "define NO_INVARIANTS, NO_PRECONDITIONS, NO_POSTCONDITIONS, NO_EXCEPTS, and NO_CHECKS instead"
  643. #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \
  644. defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \
  645. defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \
  646. defined(BOOST_CONTRACT_NO_EXCEPTS) && \
  647. defined(BOOST_CONTRACT_NO_CHECKS)
  648. /**
  649. Automatically defined by this library when contracts are not checked at all
  650. (neither for specifications nor for implementations).
  651. This macro is not a configuration macro and this library will generate a
  652. compile-time error if users try to define it directly.
  653. This library will automatically define this macro when users define all
  654. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
  655. @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
  656. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS},
  657. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}, and
  658. @RefMacro{BOOST_CONTRACT_NO_CHECKS}.
  659. For example, users can manually program @c \#ifndef statements in their code
  660. using this macro to avoid including the @c boost/contract.hpp header all
  661. together:
  662. @code
  663. #include <boost/contract/core/config.hpp>
  664. #ifndef BOOST_CONTRACT_NO_ALL
  665. #include <boost/contract.hpp>
  666. #endif
  667. @endcode
  668. Or, use the @c boost/contract_macro.hpp header and related macros instead
  669. (because the @c boost/contract_macro.hpp header is already optimized to not
  670. include other headers from this library when contracts are not checked, but
  671. recommended only for applications where it is truly necessary to completely
  672. remove contract code compilation from production code).
  673. @see @RefSect{extras.disable_contract_compilation__macro_interface_,
  674. Disable Contract Compilation}
  675. */
  676. #define BOOST_CONTRACT_NO_ALL
  677. #endif
  678. #endif // #include guard