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