config.hpp 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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. Also, this library will automatically define this macro when Boost libraries
  29. are built as dynamic libraries (e.g., defining @c BOOST_ALL_DYN_LINK).
  30. @warning In general this library will correctly check contracts at
  31. run-time only when compiled as a shared library, unless user
  32. code checks contracts in a single program unit (e.g., a single
  33. program with only statically linked libraries that check
  34. contracts).
  35. Therefore, it is recommended to build and use this library as
  36. a dynamic library by defining this macro (or equivalently by
  37. building all Boost libraries as dynamic libraries and
  38. @c BOOST_ALL_DYN_LINK is defined).
  39. @see @RefSect{getting_started.compilers_and_platforms, Compilers and
  40. Platforms}
  41. */
  42. #define BOOST_CONTRACT_DYN_LINK
  43. #elif defined(BOOST_CONTRACT_DYN_LINK) && defined(BOOST_CONTRACT_STATIC_LINK)
  44. #error "DYN_LINK defined with STATIC_LINK"
  45. #endif
  46. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  47. /**
  48. Define this macro to compile this library as a static library (not
  49. recommended).
  50. If this macro is defined, this library is compiled so it can be linked
  51. statically to user code.
  52. This library build scripts will automatically define this macro when Boost
  53. libraries are being built as static libraries.
  54. @warning This library is not guaranteed to always work correctly at
  55. run-time when this macro is defined (define
  56. @RefMacro{BOOST_CONTRACT_DYN_LINK} or @c BOOST_ALL_DYN_LINK
  57. instead).
  58. However, this macro can be defined and this library can be
  59. safely used as a static library for user code that checks
  60. contracts in a single program unit (e.g., a single program with
  61. only statically linked libraries that check contracts).
  62. @see @RefSect{getting_started.compilers_and_platforms, Compilers and
  63. Platforms}
  64. */
  65. #define BOOST_CONTRACT_STATIC_LINK
  66. #elif defined(BOOST_CONTRACT_STATIC_LINK) && defined(BOOST_CONTRACT_DYN_LINK)
  67. #error "STATIC_LINK defined with DYN_LINK"
  68. #endif
  69. #ifdef BOOST_CONTRACT_HEADER_ONLY
  70. #error "leave DYN_LINK and STATIC_LINK undefined instead"
  71. #elif (!defined(BOOST_CONTRACT_DYN_LINK) && \
  72. !defined(BOOST_CONTRACT_STATIC_LINK)) || \
  73. defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
  74. /**
  75. Automatically defined by this library when it is being used as a header-only
  76. library (not recommended).
  77. This library will define this macro when users do not define
  78. @RefMacro{BOOST_CONTRACT_DYN_LINK} (or @c BOOST_ALL_DYN_LINK) and
  79. @RefMacro{BOOST_CONTRACT_STATIC_LINK} (this macro is not a configuration
  80. macro and this library will generate a compile-time error if users try to
  81. define it directly).
  82. When used as a header-only library, this library code does not have to be
  83. compiled separately from user code, this library headers are simply included
  84. and compiled as part of the user program.
  85. @warning This library is not guaranteed to always work correctly at
  86. run-time when this macro is defined (define
  87. @RefMacro{BOOST_CONTRACT_DYN_LINK} or @c BOOST_ALL_DYN_LINK
  88. instead).
  89. However, this macro can be defined and this library can be
  90. safely used as a header-only library for user code that checks
  91. contracts in a single program unit (e.g., a single program with
  92. only statically linked libraries that check contracts).
  93. @see @RefSect{getting_started.compilers_and_platforms, Compilers and
  94. Platforms}
  95. */
  96. #define BOOST_CONTRACT_HEADER_ONLY
  97. #endif
  98. #if (!defined(BOOST_CONTRACT_DISABLE_THREADS) && \
  99. defined(BOOST_DISABLE_THREADS)) || \
  100. defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
  101. /**
  102. Define this macro to not lock internal library data for thread safety
  103. (undefined by default).
  104. Defining this macro will make the library implementation code not thread
  105. safe so this macro should not be defined unless the library is being used by
  106. single-threaded applications only.
  107. This library will automatically define this macro when Boost libraries are
  108. built without threads (e.g., defining @c BOOST_DISABLE_THREADS).
  109. @note When this macro is left undefined this library needs to internally
  110. use some sort of global lock (to ensure contract checking is
  111. globally disabled when other contracts are being checked and also to
  112. safely access failure handler functors).
  113. That could introduce an undesired amount of synchronization in some
  114. multi-threaded applications.
  115. @see @RefSect{contract_programming_overview.assertions, Assertions}
  116. */
  117. #define BOOST_CONTRACT_DISABLE_THREADS
  118. #endif
  119. #ifndef BOOST_CONTRACT_MAX_ARGS
  120. /**
  121. Maximum number of arguments for public function overrides on compilers that
  122. do not support variadic templates (default to @c 10).
  123. On compilers that do not support variadic templates, this macro is defined
  124. to the maximum number of arguments that public function overrides can have
  125. and pass to @RefFunc{boost::contract::public_function} (users can redefine
  126. this macro to a different value).
  127. On compilers that support variadic templates, this macro has no effect.
  128. @note Regardless of the value of this macro and of compiler support for
  129. variadic templates, there is an intrinsic limit of about 18
  130. arguments for public function overrides (because of similar limits
  131. in Boost.MPL and Boost.FunctionTypes internally used by this
  132. library).
  133. @see @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros}
  134. */
  135. #define BOOST_CONTRACT_MAX_ARGS 10
  136. #endif
  137. #ifndef BOOST_CONTRACT_BASES_TYPEDEF
  138. /**
  139. Define the name of the base type @c typedef (@c base_types by default).
  140. This macro expands to the name of the @c typedef that lists the base
  141. classes for subcontracting via @RefMacro{BOOST_CONTRACT_BASE_TYPES}:
  142. @code
  143. class u :
  144. #define BASES public b, private w
  145. BASES
  146. {
  147. friend class boost::contract:access;
  148. typedef BOOST_CONTRACT_BASES(BASES) BOOST_CONTRACT_TYPEDEF;
  149. #undef BASES
  150. ...
  151. };
  152. @endcode
  153. Users can redefine this macro if the @c typedef must have a name different
  154. from @c base_types (because of name clashes in user code, etc.).
  155. @see @RefSect{tutorial.base_classes__subcontracting_, Base Classes}
  156. */
  157. #define BOOST_CONTRACT_BASES_TYPEDEF base_types
  158. #endif
  159. #ifndef BOOST_CONTRACT_INVARIANT_FUNC
  160. /**
  161. Define the name of the class invariant member function (@c invariant by
  162. default).
  163. This macro expands to the name of the @c const and <c>const volatile</c>
  164. member functions that check class invariants and volatile class invariants
  165. respectively:
  166. @code
  167. class u {
  168. friend class boost::contract::access;
  169. void BOOST_CONTRACT_INVARIANT_FUNC() const {
  170. BOOST_CONTRACT_ASSERT(...);
  171. ...
  172. }
  173. void BOOST_CONTRACT_INVARIANT_FUNC() const volatile {
  174. BOOST_CONTRACT_ASSERT(...);
  175. ...
  176. }
  177. ...
  178. };
  179. @endcode
  180. Users can redefine this macro if the invariant functions must have a name
  181. different from @c invariant (because of name clashes in user code, etc.).
  182. @note C++ does not allow to overload member functions based on the
  183. @c static classifier, so this macro must always be defined to be
  184. different than the function name defined for
  185. @RefMacro{BOOST_CONTRACT_STATIC_INVARIANT_FUNC}.
  186. @see @RefSect{tutorial.class_invariants, Class Invariants},
  187. @RefSect{extras.volatile_public_functions,
  188. Volatile Public Functions}
  189. */
  190. #define BOOST_CONTRACT_INVARIANT_FUNC invariant
  191. #endif
  192. #ifndef BOOST_CONTRACT_STATIC_INVARIANT_FUNC
  193. /**
  194. Define the name of the static invariant member function (@c static_invariant
  195. by default).
  196. This macro expands to the name of the @c static member function that checks
  197. static class invariants:
  198. @code
  199. class u {
  200. friend class boost::contract::access;
  201. static void BOOST_CONTRACT_STATIC_INVARIANT_FUNC() {
  202. BOOST_CONTRACT_ASSERT(...);
  203. ...
  204. }
  205. ...
  206. };
  207. @endcode
  208. Users can redefine this macro if the static invariant function must have a
  209. name different from @c static_invariant (because of name clashes in user
  210. code, etc.).
  211. @note C++ does not allow to overload member functions based on the
  212. @c static classifier, so this macro must always be defined to be
  213. different than the function name defined for
  214. @RefMacro{BOOST_CONTRACT_INVARIANT_FUNC}.
  215. @see @RefSect{tutorial.class_invariants, Class Invariants}
  216. */
  217. #define BOOST_CONTRACT_STATIC_INVARIANT_FUNC static_invariant
  218. #endif
  219. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  220. /**
  221. Disable some compile-time errors generated by this library (undefined by
  222. default).
  223. Defining this macro disables a number of static checks and related
  224. compile-time errors generated by this library, for example:
  225. @li The static invariant member @c BOOST_CONTRACT_STATIC_INVARIANT_FUNC
  226. function must be declared @c static.
  227. @li Non-static invariant member functions @c BOOST_CONTRACT_INVARIANT_FUNC
  228. must be declared either @c const, <c>const volatile</c>, or
  229. <c>volatile const</c>.
  230. @li Derived classes that program contracts for one or more public function
  231. overrides via @RefFunc{boost::contract::public_function} must also
  232. define the @RefMacro{BOOST_CONTRACT_BASE_TYPES} @c typedef.
  233. In general, it is not recommended to define this macro because these
  234. compile-time checks can guard against misuses of this library.
  235. @see @RefSect{tutorial.class_invariants, Class Invariants},
  236. @RefSect{tutorial.base_classes__subcontracting_, Base Classes}
  237. */
  238. #define BOOST_CONTRACT_PERMISSIVE
  239. #endif
  240. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  241. /**
  242. Code block to execute if contracts are not assigned to a
  243. @RefClass{boost::contract::check} variable (undefined by default and
  244. executes @c BOOST_ASSERT(false)).
  245. In general, there is a logic error in the program when contracts are not
  246. assigned to a local variable of type @RefClass{boost::contract::check}
  247. (because that is a misuse of this library).
  248. Therefore, by default (i.e., when this macro is not defined) this library
  249. calls <c>BOOST_ASSERT(false)</c> in those cases.
  250. If this macro is defined, this library will execute the code expanded by the
  251. macro instead of calling @c BOOST_ASSERT(false) (if programmers prefer to
  252. throw an exception, etc.).
  253. This macro can be defined to be any block of code (use empty curly brackets
  254. @c {} to generate no error), for example (on GCC):
  255. @code
  256. -DBOOST_CONTRACT_ON_MISSING_CHECK_DECL='{ throw std::logic_error("missing contract check declaration"); }'
  257. @endcode
  258. @see @RefSect{tutorial, Tutorial}
  259. */
  260. #define BOOST_CONTRACT_ON_MISSING_CHECK_DECL
  261. #endif
  262. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  263. /**
  264. Define this macro to not disable other assertions while checking
  265. preconditions (undefined by default).
  266. Not disabling other assertions while checking preconditions can lead to
  267. infinite recursion in user code so by default this macro is not defined.
  268. However, the @RefSect{bibliography, [1962]} proposal does not disable
  269. assertions while checking preconditions because arguments can reach the
  270. function body unchecked if assertions are disabled while checking
  271. preconditions (e.g., when these same functions bodies are called to check
  272. the preconditions in question).
  273. This macro can be defined to obtain the behaviour specified in
  274. @RefSect{bibliography, [1962]} (at the risk of infinite recursion).
  275. @see @RefSect{contract_programming_overview.feature_summary,
  276. Feature Summary}
  277. */
  278. #define BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION
  279. #endif
  280. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  281. /**
  282. Define this macro to not disable any assertion while checking other
  283. assertions (undefined by default).
  284. Not disabling assertions while checking other assertions can lead to
  285. infinite recursion in user code so by default this macro is not defined.
  286. (Defining this macro automatically implies that other assertion checking is
  287. disabled while checking preconditions as if
  288. @RefMacro{BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION} was also
  289. defined.)
  290. @see @RefSect{contract_programming_overview.feature_summary,
  291. Feature Summary}
  292. */
  293. #define BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION
  294. #endif
  295. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
  296. /**
  297. Define this macro to evaluate and check audit assertions at run-time
  298. (undefined by default).
  299. Audit assertions and implementation checks programmed via
  300. @RefMacro{BOOST_CONTRACT_ASSERT_AUDIT} and
  301. @RefMacro{BOOST_CONTRACT_CHECK_AUDIT} are always compiled and validated
  302. syntactically.
  303. However, they are not evaluated and checked at run-time unless
  304. this macro is defined (because these conditions can be computationally
  305. expensive, at least compared to the cost of executing the 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 does not perform implementation checks (undefined
  313. by 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. Users can manually program @c \#ifndef statements in their code using this
  318. macro to completely disable compilation of implementation checks or use
  319. @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. Users can manually program @c \#ifndef statements in their code using this
  337. macro to completely disable compilation of preconditions or use the macros
  338. defined in @c boost/contract_macro.hpp (recommended only for applications
  339. where it is truly necessary to completely remove contract code compilation
  340. 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. Users can manually program @c \#ifndef statements in their code using this
  357. macro to completely disable compilation of postconditions or use the macros
  358. defined in @c boost/contract_macro.hpp (recommended only for applications
  359. where it is truly necessary to completely remove contract code compilation
  360. 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. Users can manually program @c \#ifndef statements in their code using this
  381. macro to completely disable compilation of exception guarantees or use the
  382. macros defined in @c boost/contract_macro.hpp (recommended only for
  383. applications where it is truly necessary to completely remove contract code
  384. 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. Users can manually program @c \#ifndef statements in their code using this
  409. macro to completely disable compilation of entry class invariants or use the
  410. macros defined in @c boost/contract_macro.hpp (recommended only for
  411. applications where it is truly necessary to completely remove contract code
  412. 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. Users can manually program @c \#ifndef statements in their code using this
  435. macro to completely disable compilation of exit class invariants or use the
  436. macros defined in @c boost/contract_macro.hpp (recommended only for
  437. applications where it is truly necessary to completely remove contract code
  438. 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. Users can manually program @c \#ifndef statements in their code using this
  459. macro to completely disable compilation of class invariants or use the
  460. 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 library will define this macro when users define both
  482. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and
  483. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration
  484. macro and this library will generate a compile-time error if users try to
  485. define it directly).
  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_value_copies_at_body,
  493. Old Value Copies 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 library will define this macro when users define all
  509. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
  510. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
  511. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration
  512. macro and this library will generate a compile-time error if users try to
  513. define it directly).
  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 library will define this macro when users define all
  537. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
  538. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
  539. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration
  540. macro and this library will generate a compile-time error if users try to
  541. define it directly).
  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 library will define this macro when users define all
  563. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
  564. @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
  565. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
  566. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration
  567. macro and this library will generate a compile-time error if users try to
  568. define it directly).
  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 and protected functions.
  588. This library will define this macro when users define all
  589. @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
  590. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
  591. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration
  592. macro and this library will generate a compile-time error if users try to
  593. define it directly).
  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 and
  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 library will define this macro when users define all
  623. @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
  624. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS},
  625. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}, and
  626. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} (this macro is not a configuration
  627. macro and this library will generate a compile-time error if users try to
  628. define it directly).
  629. Users can manually program @c \#ifndef statements in their code using this
  630. macro to completely disable compilation of contracts within specifications
  631. or use the macros defined in @c boost/contract_macro.hpp (recommended only
  632. for applications where it is truly necessary to completely remove contract
  633. code compilation from production code).
  634. @see @RefSect{extras.disable_contract_compilation__macro_interface_,
  635. Disable Contract Compilation}
  636. */
  637. #define BOOST_CONTRACT_NO_CONDITIONS
  638. #endif
  639. #ifdef BOOST_CONTRACT_NO_ALL
  640. #error "define NO_INVARIANTS, NO_PRECONDITIONS, NO_POSTCONDITIONS, NO_EXCEPTS, and NO_CHECKS instead"
  641. #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \
  642. defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \
  643. defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \
  644. defined(BOOST_CONTRACT_NO_EXCEPTS) && \
  645. defined(BOOST_CONTRACT_NO_CHECKS)
  646. /**
  647. Automatically defined by this library when contracts are not checked at all.
  648. This library will define this macro when users define all
  649. @RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
  650. @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
  651. @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS},
  652. @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}, and
  653. @RefMacro{BOOST_CONTRACT_NO_CHECKS} (this macro is not a configuration
  654. macro and this library will generate a compile-time error if users try to
  655. define it directly).
  656. For example, users can manually program @c \#ifndef statements in their code
  657. using this macro to avoid including the @c boost/contract.hpp header all
  658. together:
  659. @code
  660. #include <boost/contract/core/config.hpp>
  661. #ifndef BOOST_CONTRACT_NO_ALL
  662. #include <boost/contract.hpp>
  663. #endif
  664. @endcode
  665. Or, use the @c boost/contract_macro.hpp header and related macros instead
  666. (because the @c boost/contract_macro.hpp header is already optimized to not
  667. include other headers from this library when contracts are not checked, but
  668. recommended only for applications where it is truly necessary to completely
  669. remove contract code compilation from production code).
  670. @see @RefSect{extras.disable_contract_compilation__macro_interface_,
  671. Disable Contract Compilation}
  672. */
  673. #define BOOST_CONTRACT_NO_ALL
  674. #endif
  675. #endif // #include guard