update boost

This commit is contained in:
2023-11-24 12:56:13 -06:00
parent cfc99971af
commit 19d727037a
9260 changed files with 849256 additions and 299957 deletions

View File

@@ -43,23 +43,24 @@ namespace boost { namespace contract {
#endif
/**
Friend this class to declare invariants and base types as private members.
Declare this class as friend to program invariants and base types as private
members.
Declare this class a friend of the user-defined class specifying the contracts
in order to declare the invariant functions and the base types @c typedef as
and then invariant functions and the base types @c typedef can be declared as
non-public members:
@code
class u :
class u
#define BASES public b, private w
BASES
: BASES
{
friend class boost::contract::access;
typedef BOOST_CONTRACT_BASES(BASES) base_types; // Private.
typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types; // Private.
#undef BASES
void invariant() const { ... } // Private.
void invariant() const { ... } // Private (same for static and volatile).
public:
...
@@ -67,9 +68,10 @@ public:
@endcode
In real code, programmers will likely chose to declare this class as friend so
to fully control public interfaces of their user-defined classes.
to fully control public interfaces of their user-defined classes (this is not
extensively done in the examples of this documentation only for brevity).
This class is not intended to be directly used by programmers a part from
declaring it @c friend (and that is why this class does not have any public
being declared as @c friend (and that is why this class does not have any public
member and it is not copyable).
@warning Not declaring this class friend of user-defined classes will cause
@@ -79,8 +81,8 @@ member and it is not copyable).
instead fail SFINAE and no compiler error will be reported while
invariants and subcontracting will be silently skipped at run-time.
Therefore, programmers must make sure to either declare this class
as friend (preferred) or to always declare invariant functions and
base types @c typedef as public members.
as friend or to always declare invariant functions and base types
@c typedef as public members.
@see @RefSect{advanced.access_specifiers, Access Specifiers}
*/

View File

@@ -27,7 +27,7 @@ Macros for implementation checks.
@code
void f() {
...
BOOST_CONTRACT_CHECK(...);
BOOST_CONTRACT_CHECK(cond);
...
}
@endcode
@@ -41,7 +41,7 @@ Macros for implementation checks.
@param cond Boolean condition to check within implementation code (function
body, etc.).
(This is not a variadic macro parameter so any comma it might
contain must be protected by round parenthesis,
contain must be protected by round parenthesis and
@c BOOST_CONTRACT_CHECK((cond)) will always work.)
*/
#define BOOST_CONTRACT_CHECK(cond)
@@ -58,11 +58,11 @@ Macros for implementation checks.
#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
/**
Preferred way to assert implementation check conditions that are
computationally expensive, at least compared to the cost of executing the
function body.
computationally expensive, at least compared to the computational cost of
executing the function body.
The specified condition will always be compiled and validated
syntactically, but it will not be evaluated at run-time unless
The specified condition will always be compiled and validated syntactically,
but it will not be checked at run-time unless
@RefMacro{BOOST_CONTRACT_AUDITS} is defined (undefined by default).
This macro is defined by code equivalent to:
@@ -87,7 +87,7 @@ Macros for implementation checks.
@param cond Boolean condition to check within implementation code (function
body, etc.).
(This is not a variadic macro parameter so any comma it might
contain must be protected by round parenthesis,
contain must be protected by round parenthesis and
@c BOOST_CONTRACT_CHECK_AUDIT((cond)) will always work.)
*/
#define BOOST_CONTRACT_CHECK_AUDIT(cond)
@@ -100,11 +100,12 @@ Macros for implementation checks.
#endif
/**
Preferred way to assert implementation check conditions that are computationally
prohibitive, at least compared to the cost of executing the function body.
Preferred way to document in the code implementation check conditions that are
computationally prohibitive, at least compared to the computational cost of
executing the function body.
The specified condition will always be compiled and validated
syntactically, but it will never be evaluated at run-time.
The specified condition will always be compiled and validated syntactically, but
it will never be checked at run-time.
This macro is defined by code equivalent to:
@code
@@ -123,7 +124,7 @@ defining macros similar to the one above.
@param cond Boolean condition to check within implementation code (function
body, etc.).
(This is not a variadic macro parameter so any comma it might
contain must be protected by round parenthesis,
contain must be protected by round parenthesis and
@c BOOST_CONTRACT_CHECK_AXIOM((cond)) will always work.)
*/
#define BOOST_CONTRACT_CHECK_AXIOM(cond) \

View File

@@ -33,21 +33,19 @@ Configure this library compile-time and run-time behaviours.
If this macro is defined, this library is compiled so it can be linked
as a shared library (a.k.a., Dynamically Linked Library or DLL) to user
code.
Also, this library will automatically define this macro when Boost libraries
are built as dynamic libraries (e.g., defining @c BOOST_ALL_DYN_LINK).
This library will automatically define this macro when Boost libraries are
built as shared libraries (e.g., defining @c BOOST_ALL_DYN_LINK or using
<c>bjam link=shared ...</c>).
@warning In general this library will correctly check contracts at
run-time only when compiled as a shared library, unless user
code checks contracts in a single program unit (e.g., a single
program with only statically linked libraries that check
contracts).
program with only statically linked libraries).
Therefore, it is recommended to build and use this library as
a dynamic library by defining this macro (or equivalently by
building all Boost libraries as dynamic libraries and
@c BOOST_ALL_DYN_LINK is defined).
a shared library by defining this macro (or equivalently by
building all Boost libraries as shared libraries).
@see @RefSect{getting_started.compilers_and_platforms, Compilers and
Platforms}
@see @RefSect{getting_started, Getting Started}
*/
#define BOOST_CONTRACT_DYN_LINK
#elif defined(BOOST_CONTRACT_DYN_LINK) && defined(BOOST_CONTRACT_STATIC_LINK)
@@ -61,8 +59,8 @@ Configure this library compile-time and run-time behaviours.
If this macro is defined, this library is compiled so it can be linked
statically to user code.
This library build scripts will automatically define this macro when Boost
libraries are being built as static libraries.
This library will automatically define this macro when Boost libraries
are built as static libraries.
@warning This library is not guaranteed to always work correctly at
run-time when this macro is defined (define
@@ -71,10 +69,9 @@ Configure this library compile-time and run-time behaviours.
However, this macro can be defined and this library can be
safely used as a static library for user code that checks
contracts in a single program unit (e.g., a single program with
only statically linked libraries that check contracts).
only statically linked libraries).
@see @RefSect{getting_started.compilers_and_platforms, Compilers and
Platforms}
@see @RefSect{getting_started, Getting Started}
*/
#define BOOST_CONTRACT_STATIC_LINK
#elif defined(BOOST_CONTRACT_STATIC_LINK) && defined(BOOST_CONTRACT_DYN_LINK)
@@ -90,11 +87,11 @@ Configure this library compile-time and run-time behaviours.
Automatically defined by this library when it is being used as a header-only
library (not recommended).
This library will define this macro when users do not define
This macro is not a configuration macro and this library will generate a
compile-time error if users try to define it directly.
This library will automatically define this macro when users do not define
@RefMacro{BOOST_CONTRACT_DYN_LINK} (or @c BOOST_ALL_DYN_LINK) and
@RefMacro{BOOST_CONTRACT_STATIC_LINK} (this macro is not a configuration
macro and this library will generate a compile-time error if users try to
define it directly).
@RefMacro{BOOST_CONTRACT_STATIC_LINK}.
When used as a header-only library, this library code does not have to be
compiled separately from user code, this library headers are simply included
and compiled as part of the user program.
@@ -106,10 +103,9 @@ Configure this library compile-time and run-time behaviours.
However, this macro can be defined and this library can be
safely used as a header-only library for user code that checks
contracts in a single program unit (e.g., a single program with
only statically linked libraries that check contracts).
only statically linked libraries).
@see @RefSect{getting_started.compilers_and_platforms, Compilers and
Platforms}
@see @RefSect{getting_started, Getting Started}
*/
#define BOOST_CONTRACT_HEADER_ONLY
#endif
@@ -144,14 +140,14 @@ Configure this library compile-time and run-time behaviours.
Maximum number of arguments for public function overrides on compilers that
do not support variadic templates (default to @c 10).
On compilers that do not support variadic templates, this macro is defined
to the maximum number of arguments that public function overrides can have
and pass to @RefFunc{boost::contract::public_function} (users can redefine
this macro to a different value).
On compilers that do not support C++11 variadic templates, this macro is
defined to the maximum number of arguments that public function overrides
can have and pass to @RefFunc{boost::contract::public_function} (users can
redefine this macro to a different value).
On compilers that support variadic templates, this macro has no effect.
@note Regardless of the value of this macro and of compiler support for
variadic templates, there is an intrinsic limit of about 18
variadic templates, there might be an intrinsic limit of about 18
arguments for public function overrides (because of similar limits
in Boost.MPL and Boost.FunctionTypes internally used by this
library).
@@ -169,21 +165,22 @@ Configure this library compile-time and run-time behaviours.
classes for subcontracting via @RefMacro{BOOST_CONTRACT_BASE_TYPES}:
@code
class u :
class u
#define BASES public b, private w
BASES
: BASES
{
friend class boost::contract:access;
typedef BOOST_CONTRACT_BASES(BASES) BOOST_CONTRACT_TYPEDEF;
typedef BOOST_CONTRACT_BASE_TYPES(BASES) BOOST_CONTRACT_TYPEDEF;
#undef BASES
...
};
@endcode
Users can redefine this macro if the @c typedef must have a name different
from @c base_types (because of name clashes in user code, etc.).
When used this way, users can redefine this macro if the @c typedef must
have a name different from @c base_types (because of name clashes in user
code, etc.).
@see @RefSect{tutorial.base_classes__subcontracting_, Base Classes}
*/
@@ -217,8 +214,9 @@ Configure this library compile-time and run-time behaviours.
};
@endcode
Users can redefine this macro if the invariant functions must have a name
different from @c invariant (because of name clashes in user code, etc.).
When used this way, users can redefine this macro if the invariant functions
must have a name different from @c invariant (because of name clashes in
user code, etc.).
@note C++ does not allow to overload member functions based on the
@c static classifier, so this macro must always be defined to be
@@ -253,9 +251,9 @@ Configure this library compile-time and run-time behaviours.
};
@endcode
Users can redefine this macro if the static invariant function must have a
name different from @c static_invariant (because of name clashes in user
code, etc.).
When used this way, users can redefine this macro if the static invariant
function must have a name different from @c static_invariant (because of
name clashes in user code, etc.).
@note C++ does not allow to overload member functions based on the
@c static classifier, so this macro must always be defined to be
@@ -275,11 +273,11 @@ Configure this library compile-time and run-time behaviours.
Defining this macro disables a number of static checks and related
compile-time errors generated by this library, for example:
@li The static invariant member @c BOOST_CONTRACT_STATIC_INVARIANT_FUNC
function must be declared @c static.
@li Non-static invariant member functions @c BOOST_CONTRACT_INVARIANT_FUNC
must be declared either @c const, <c>const volatile</c>, or
<c>volatile const</c>.
@li The static invariant member function named as
@c BOOST_CONTRACT_STATIC_INVARIANT_FUNC must be declared @c static.
@li Non-static invariant member functions named as
@c BOOST_CONTRACT_INVARIANT_FUNC must be declared either @c const,
<c>const volatile</c>, or <c>volatile const</c>.
@li Derived classes that program contracts for one or more public function
overrides via @RefFunc{boost::contract::public_function} must also
define the @RefMacro{BOOST_CONTRACT_BASE_TYPES} @c typedef.
@@ -296,22 +294,23 @@ Configure this library compile-time and run-time behaviours.
#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
/**
Code block to execute if contracts are not assigned to a
@RefClass{boost::contract::check} variable (undefined by default and
executes @c BOOST_ASSERT(false)).
@RefClass{boost::contract::check} variable (undefined and executes
@c BOOST_ASSERT(false) by default).
In general, there is a logic error in the program when contracts are not
assigned to a local variable of type @RefClass{boost::contract::check}
(because that is a misuse of this library).
explicitly assigned to a local variable of type
@RefClass{boost::contract::check} and without using C++11 @c auto
declarations (because that is a misuse of this library).
Therefore, by default (i.e., when this macro is not defined) this library
calls <c>BOOST_ASSERT(false)</c> in those cases.
If this macro is defined, this library will execute the code expanded by the
macro instead of calling @c BOOST_ASSERT(false) (if programmers prefer to
throw an exception, etc.).
If this macro is defined, this library will execute the code expanded by
this macro instead of calling @c BOOST_ASSERT(false) (if programmers prefer
to throw an exception, etc.).
This macro can be defined to be any block of code (use empty curly brackets
@c {} to generate no error), for example (on GCC):
This macro can also be defined to be any block of code (and use empty curly
brackets @c {} to generate no error, not recommended), for example (on GCC):
@code
-DBOOST_CONTRACT_ON_MISSING_CHECK_DECL='{ throw std::logic_error("missing contract check declaration"); }'
gcc -DBOOST_CONTRACT_ON_MISSING_CHECK_DECL='{ throw std::logic_error("missing contract check declaration"); }' ...
@endcode
@see @RefSect{tutorial, Tutorial}
@@ -327,13 +326,13 @@ Configure this library compile-time and run-time behaviours.
Not disabling other assertions while checking preconditions can lead to
infinite recursion in user code so by default this macro is not defined.
However, the @RefSect{bibliography, [1962]} proposal does not disable
However, the @RefSect{bibliography, [N1962]} proposal does not disable
assertions while checking preconditions because arguments can reach the
function body unchecked if assertions are disabled while checking
preconditions (e.g., when these same functions bodies are called to check
the preconditions in question).
This macro can be defined to obtain the behaviour specified in
@RefSect{bibliography, [1962]} (at the risk of infinite recursion).
@RefSect{bibliography, [N1962]} (at the risk of infinite recursion).
@see @RefSect{contract_programming_overview.feature_summary,
Feature Summary}
@@ -370,7 +369,8 @@ Configure this library compile-time and run-time behaviours.
syntactically.
However, they are not evaluated and checked at run-time unless
this macro is defined (because these conditions can be computationally
expensive, at least compared to the cost of executing the function body).
expensive, at least compared to the computational cost of executing the
function body).
@see @RefSect{extras.assertion_levels, Assertion Levels}
*/
@@ -379,15 +379,15 @@ Configure this library compile-time and run-time behaviours.
#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN
/**
If defined, this library does not perform implementation checks (undefined
by default).
If defined, this library disables implementation checks (undefined by
default).
If this macro is defined, this library internal code is also optimized to
reduce compile-time (not just run-time) overhead associated with
implementation checks.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of implementation checks or use
@RefMacro{BOOST_CONTRACT_CHECK} (recommended).
In addition, users can manually program @c \#ifndef statements in their code
using this macro to completely disable compilation of implementation checks
or use @RefMacro{BOOST_CONTRACT_CHECK} (recommended).
@see @RefSect{advanced.implementation_checks,
Implementation Checks},
@@ -407,11 +407,11 @@ Configure this library compile-time and run-time behaviours.
If this macro is defined, this library internal code is also optimized to
reduce compile-time (not just run-time) overhead associated with
checking preconditions.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of preconditions or use the macros
defined in @c boost/contract_macro.hpp (recommended only for applications
where it is truly necessary to completely remove contract code compilation
from production code).
In addition, users can manually program @c \#ifndef statements in their code
using this macro to completely disable compilation of preconditions or use
the macros defined in @c boost/contract_macro.hpp (recommended only for
applications where it is truly necessary to completely remove contract code
compilation from production code).
@see @RefSect{tutorial.preconditions, Preconditions},
@RefSect{extras.disable_contract_checking,
@@ -430,11 +430,11 @@ Configure this library compile-time and run-time behaviours.
If this macro is defined, this library internal code is also optimized to
reduce compile-time (not just run-time) overhead associated with
checking postconditions.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of postconditions or use the macros
defined in @c boost/contract_macro.hpp (recommended only for applications
where it is truly necessary to completely remove contract code compilation
from production code).
In addition, users can manually program @c \#ifndef statements in their code
using this macro to completely disable compilation of postconditions or use
the macros defined in @c boost/contract_macro.hpp (recommended only for
applications where it is truly necessary to completely remove contract code
compilation from production code).
It is necessary to disable both postconditions and exception guarantees
defining @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and
@@ -458,11 +458,11 @@ Configure this library compile-time and run-time behaviours.
If this macro is defined, this library internal code is also optimized to
reduce compile-time (not just run-time) overhead associated with
checking exception guarantees.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of exception guarantees or use the
macros defined in @c boost/contract_macro.hpp (recommended only for
applications where it is truly necessary to completely remove contract code
compilation from production code).
In addition, users can manually program @c \#ifndef statements in their code
using this macro to completely disable compilation of exception guarantees
or use the macros defined in @c boost/contract_macro.hpp (recommended only
for applications where it is truly necessary to completely remove contract
code compilation from production code).
It is necessary to disable both postconditions and exception guarantees
defining @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and
@@ -490,11 +490,11 @@ Configure this library compile-time and run-time behaviours.
If this macro is defined, this library internal code is also optimized to
reduce compile-time (not just run-time) overhead associated with
checking class invariants at entry.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of entry class invariants or use the
macros defined in @c boost/contract_macro.hpp (recommended only for
applications where it is truly necessary to completely remove contract code
compilation from production code).
In addition, users can manually program @c \#ifndef statements in their code
using this macro to completely disable compilation of entry class invariants
or use the macros defined in @c boost/contract_macro.hpp (recommended only
for applications where it is truly necessary to completely remove contract
code compilation from production code).
This macro is automatically defined when
@RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined.
@@ -520,11 +520,11 @@ Configure this library compile-time and run-time behaviours.
If this macro is defined, this library internal code is also optimized to
reduce compile-time (not just run-time) overhead associated with
checking class invariants at exit.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of exit class invariants or use the
macros defined in @c boost/contract_macro.hpp (recommended only for
applications where it is truly necessary to completely remove contract code
compilation from production code).
In addition, users can manually program @c \#ifndef statements in their code
using this macro to completely disable compilation of exit class invariants
or use the macros defined in @c boost/contract_macro.hpp (recommended only
for applications where it is truly necessary to completely remove contract
code compilation from production code).
This macro is automatically defined when
@RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined.
@@ -548,9 +548,9 @@ Configure this library compile-time and run-time behaviours.
If this macro is defined, this library internal code is also optimized to
reduce compile-time (not just run-time) overhead associated with
checking class invariants.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of class invariants or use the
macros defined in @c boost/contract_macro.hpp (recommended only for
In addition, users can manually program @c \#ifndef statements in their code
using this macro to completely disable compilation of class invariants or
use the macros defined in @c boost/contract_macro.hpp (recommended only for
applications where it is truly necessary to completely remove contract code
compilation from production code).
@@ -575,11 +575,11 @@ Configure this library compile-time and run-time behaviours.
Automatically defined by this library when old value copies are not to be
performed.
This library will define this macro when users define both
This macro is not a configuration macro and this library will generate a
compile-time error if users try to define it directly.
This library will automatically define this macro when users define both
@RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration
macro and this library will generate a compile-time error if users try to
define it directly).
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS}.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of old value copies or use the
macros defined in @c boost/contract_macro.hpp (recommended only for
@@ -587,8 +587,8 @@ Configure this library compile-time and run-time behaviours.
compilation from production code).
@see @RefSect{tutorial.old_values, Old Values},
@RefSect{advanced.old_value_copies_at_body,
Old Value Copies at Body},
@RefSect{advanced.old_values_copied_at_body,
Old Values Copied at Body},
@RefSect{extras.disable_contract_compilation__macro_interface_,
Disable Contract Compilation}
*/
@@ -605,12 +605,12 @@ Configure this library compile-time and run-time behaviours.
Automatically defined by this library when contracts are not checked for
constructors.
This library will define this macro when users define all
This macro is not a configuration macro and this library will generate a
compile-time error if users try to define it directly.
This library will automatically define this macro when users define all
@RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
@RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration
macro and this library will generate a compile-time error if users try to
define it directly).
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS}.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of contracts for constructors or use
the macros defined in @c boost/contract_macro.hpp (recommended only for
@@ -637,12 +637,12 @@ Configure this library compile-time and run-time behaviours.
Automatically defined by this library when contracts are not checked for
destructors.
This library will define this macro when users define all
This macro is not a configuration macro and this library will generate a
compile-time error if users try to define it directly.
This library will automatically define this macro when users define all
@RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
@RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration
macro and this library will generate a compile-time error if users try to
define it directly).
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS}.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of contracts for destructors or use
the macros defined in @c boost/contract_macro.hpp (recommended only for
@@ -666,13 +666,13 @@ Configure this library compile-time and run-time behaviours.
Automatically defined by this library when contracts are not checked for
public functions.
This library will define this macro when users define all
This macro is not a configuration macro and this library will generate a
compile-time error if users try to define it directly.
This library will automatically define this macro when users define all
@RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
@RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
@RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration
macro and this library will generate a compile-time error if users try to
define it directly).
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS}.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of contracts for public functions or
use the macros defined in @c boost/contract_macro.hpp (recommended only for
@@ -693,14 +693,14 @@ Configure this library compile-time and run-time behaviours.
defined(BOOST_CONTRACT_NO_EXCEPTS)
/**
Automatically defined by this library when contracts are not checked for
non-member, private and protected functions.
non-member, private, or protected functions.
This library will define this macro when users define all
This macro is not a configuration macro and this library will generate a
compile-time error if users try to define it directly.
This library will automatically define this macro when users define all
@RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
@RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration
macro and this library will generate a compile-time error if users try to
define it directly).
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS}.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of contracts for non-member,
private and protected functions, or use the macros defined in
@@ -708,7 +708,7 @@ Configure this library compile-time and run-time behaviours.
truly necessary to completely remove contract code compilation from
production code).
This macro is also used when contracts are not checked for private and
This macro is also used when contracts are not checked for private or
protected functions, lambda functions, code blocks, loops, etc.
@see @RefSect{tutorial.non_member_functions, Non-Member Functions},
@@ -733,18 +733,20 @@ Configure this library compile-time and run-time behaviours.
preconditions, postconditions, exceptions guarantees, and class invariants
(excluding implementation checks).
This library will define this macro when users define all
This macro is not a configuration macro and this library will generate a
compile-time error if users try to define it directly.
This library will automatically define this macro when users define all
@RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
@RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS},
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS}, and
@RefMacro{BOOST_CONTRACT_NO_INVARIANTS} (this macro is not a configuration
macro and this library will generate a compile-time error if users try to
define it directly).
@RefMacro{BOOST_CONTRACT_NO_INVARIANTS}.
Users can manually program @c \#ifndef statements in their code using this
macro to completely disable compilation of contracts within specifications
or use the macros defined in @c boost/contract_macro.hpp (recommended only
for applications where it is truly necessary to completely remove contract
code compilation from production code).
(so excluding implementation checks which are contracts within
implementations instead), or use the macros defined in
@c boost/contract_macro.hpp (recommended only for applications where it is
truly necessary to completely remove contract code compilation from
production code).
@see @RefSect{extras.disable_contract_compilation__macro_interface_,
Disable Contract Compilation}
@@ -760,16 +762,17 @@ Configure this library compile-time and run-time behaviours.
defined(BOOST_CONTRACT_NO_EXCEPTS) && \
defined(BOOST_CONTRACT_NO_CHECKS)
/**
Automatically defined by this library when contracts are not checked at all.
Automatically defined by this library when contracts are not checked at all
(neither for specifications nor for implementations).
This library will define this macro when users define all
This macro is not a configuration macro and this library will generate a
compile-time error if users try to define it directly.
This library will automatically define this macro when users define all
@RefMacro{BOOST_CONTRACT_NO_INVARIANTS},
@RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS},
@RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS},
@RefMacro{BOOST_CONTRACT_NO_EXCEPTS}, and
@RefMacro{BOOST_CONTRACT_NO_CHECKS} (this macro is not a configuration
macro and this library will generate a compile-time error if users try to
define it directly).
@RefMacro{BOOST_CONTRACT_NO_CHECKS}.
For example, users can manually program @c \#ifndef statements in their code
using this macro to avoid including the @c boost/contract.hpp header all
together:

View File

@@ -36,7 +36,9 @@ initialize other base classes):
public b
: BASES
{
...
friend class boost::contract::access;
typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
#undef BASES
public:
@@ -60,10 +62,11 @@ In addition, this class should never be declared as a virtual base (because
virtual bases are initialized only once across the entire inheritance hierarchy
preventing preconditions of other base classes from being checked).
Unions cannot have base classes in C++ so this class can be used to declare a
local object within the constructor definition just before
@RefFunc{boost::contract::constructor} is used (see
@RefSect{extras.unions, Unions}).
This class cannot be used this way in a @c union because unions cannot have base
classes in C++.
Instead, this class is used in a @c union to declare a local object within the
constructor definition just before @RefFunc{boost::contract::constructor} is
used (see @RefSect{extras.unions, Unions}).
@see @RefSect{tutorial.constructors, Constructors}
@@ -79,9 +82,10 @@ public:
This is implicitly called for those constructors of the contracted class
that do not specify preconditions.
@note Calling this default constructor should amount to negligible
compile-time and run-time overheads (likely to be optimized away
completely by most compilers).
@note The implementation of this library is optimized so that calling this
default constructor should amount to negligible compile-time and
run-time overheads (likely to be optimized away completely by most
compilers).
*/
constructor_precondition() {}

View File

@@ -66,11 +66,15 @@ public:
Exception thrown when inconsistent return values are passed to overridden
virtual public functions.
This exception is internally thrown by this library when programmers specify
return values for public function overrides in derived classes that are not
consistent with the return types of the virtual public functions being
overridden in the base classes.
This allows this library to give more descriptive error messages in such cases.
This exception is thrown when programmers pass to this library return value
parameters for public function overrides in derived classes that are not
consistent with the return type parameter passed for the virtual public function
being overridden from the base classes.
This allows this library to give more descriptive error messages in such cases
of misuse.
This exception is internally thrown by this library and programmers should not
need to throw it from user code.
@see @RefSect{tutorial.public_function_overrides__subcontracting_,
Public Function Overrides}
@@ -117,10 +121,10 @@ This exception is thrown by code expanded by @RefMacro{BOOST_CONTRACT_ASSERT}
This exception is typically used to report contract assertion failures because
it contains detailed information about the file name, line number, and source
code of the asserted condition (so it can be used by this library to provide
detailed error messages).
detailed error messages when handling contract assertion failures).
However, any other exception can be used to report a contract assertion failure
(including user-defined exceptions).
This library will call the appropriate contract failure handler function
(@RefFunc{boost::contract::precondition_failure}, etc.) when this or any other
exception is thrown while checking contracts (by default, these failure handler
@@ -171,7 +175,8 @@ public:
@b Throws: This is declared @c noexcept (or @c throw() before C++11).
@return A string formatted similarly to the following:
<c>assertion "`code()`" failed: file "`file()`", line \`line()\`</c>.
<c>assertion "`code()`" failed: file "`file()`", line \`line()\`</c>
(where `` indicate execution quotes).
File, line, and code will be omitted from this string if they were
not specified when constructing this object.
*/
@@ -236,7 +241,8 @@ enum from {
from_destructor,
/**
Assertion failed when checking contracts for functions (members or not).
Assertion failed when checking contracts for functions (members or not,
public or not).
*/
from_function
};
@@ -568,7 +574,7 @@ Set a new failure handler and returns it.
@param f New failure handler functor to set.
@return Same failure handler functor @p f passed as parameter (e.g., fr
@return Same failure handler functor @p f passed as parameter (e.g., for
concatenating function calls).
@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure},
@@ -703,7 +709,7 @@ inline void except_failure(from where) /* can throw */ {
}
/**
Set failure handler for old value copies at body.
Set failure handler for old values copied at body.
Set a new failure handler and returns it.
@@ -715,7 +721,7 @@ Set a new failure handler and returns it.
concatenating function calls).
@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure},
@RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body}
@RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body}
*/
inline from_failure_handler const& set_old_failure(from_failure_handler const&
f) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ {
@@ -727,7 +733,7 @@ inline from_failure_handler const& set_old_failure(from_failure_handler const&
}
/**
Return failure handler currently set for old value copies at body.
Return failure handler currently set for old values copied at body.
This is often called only internally by this library.
@@ -736,7 +742,7 @@ This is often called only internally by this library.
@return A copy of the failure handler currently set.
@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure},
@RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body}
@RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body}
*/
inline from_failure_handler get_old_failure()
/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ {
@@ -748,7 +754,7 @@ inline from_failure_handler get_old_failure()
}
/**
Call failure handler for old value copies at body.
Call failure handler for old values copied at body.
This is often called only internally by this library.
@@ -761,7 +767,7 @@ This is often called only internally by this library.
throw exceptions instead of terminating the program).
@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure},
@RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body}
@RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body}
*/
inline void old_failure(from where) /* can throw */ {
#ifndef BOOST_CONTRACT_DISABLE_THREADS

View File

@@ -8,10 +8,10 @@
// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
/** @file
Specify preconditions, old value copies at body, postconditions, and exception
Specify preconditions, old values copied at body, postconditions, and exception
guarantees
Preconditions, old value copies at body, postconditions, and exception
Preconditions, old values copied at body, postconditions, and exception
guarantees are all optionals but, when they are specified, they need to be
specified in that order.
*/
@@ -42,7 +42,9 @@ specified in that order.
// is used instead of `check c = ...` but only up to C++17. C++17 strong copy
// elision on function return values prevents this lib from generating a
// compile-time error in those cases, but the lib will still generate a run-time
// error according with ON_MISSING_CHECK_DECL.
// error according with ON_MISSING_CHECK_DECL. Furthermore, on some C++98
// compilers, this private copy ctor gives a warning (because of lack of copy
// optimization on those compilers), this warning can be ignored.
#if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \
defined(BOOST_CONTRACT_STATIC_LINK)
#define BOOST_CONTRACT_SPECIFY_CLASS_IMPL_(class_type, cond_type) \
@@ -138,7 +140,7 @@ Used to prevent setting other contract conditions after exception guarantees.
This class has no member function so it is used to prevent specifying additional
functors to check any other contract.
This object is internally constructed by this library when users specify
This object is internally constructed by the library when users specify
contracts calling @RefFunc{boost::contract::function} and similar functions
(that is why this class does not have a public constructor).
@@ -149,11 +151,11 @@ public:
/**
Destruct this object.
@b Throws: This can throw in case programmers specify failure handlers that
throw exceptions instead of terminating the program (see
@b Throws: This is declared @c noexcept(false) since C++11 to allow users
to program failure handlers that throw exceptions on contract
assertion failures (not the default, see
@RefSect{advanced.throw_on_failures__and__noexcept__,
Throw on Failure}).
(This is declared @c noexcept(false) since C++11.)
*/
~specify_nothing() BOOST_NOEXCEPT_IF(false) {}
@@ -186,7 +188,7 @@ Allow to specify exception guarantees.
Allow to specify the functor this library will call to check exception
guarantees.
This object is internally constructed by this library when users specify
This object is internally constructed by the library when users specify
contracts calling @RefFunc{boost::contract::function} and similar functions
(that is why this class does not have a public constructor).
@@ -197,11 +199,11 @@ public:
/**
Destruct this object.
@b Throws: This can throw in case programmers specify failure handlers that
throw exceptions instead of terminating the program (see
@b Throws: This is declared @c noexcept(false) since C++11 to allow users
to program failure handlers that throw exceptions on contract
assertion failures (not the default, see
@RefSect{advanced.throw_on_failures__and__noexcept__,
Throw on Failure}).
(This is declared @c noexcept(false) since C++11.)
*/
~specify_except() BOOST_NOEXCEPT_IF(false) {}
@@ -222,9 +224,13 @@ public:
by this function does not allow to specify any additional contract.
*/
template<typename F>
specify_nothing except(F const& f) {
BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_
}
specify_nothing except(
F const&
#if !defined(BOOST_CONTRACT_NO_EXCEPTS) || \
defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
f
#endif // Else, no name (avoid unused param warning).
) { BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ }
/** @cond */
private:
@@ -251,7 +257,7 @@ Allow to specify postconditions or exception guarantees.
Allow to specify functors this library will call to check postconditions or
exception guarantees.
This object is internally constructed by this library when users specify
This object is internally constructed by the library when users specify
contracts calling @RefFunc{boost::contract::function} and similar functions
(that is why this class does not have a public constructor).
@@ -259,9 +265,12 @@ contracts calling @RefFunc{boost::contract::function} and similar functions
@RefSect{tutorial.exception_guarantees, Exception Guarantees}
@tparam VirtualResult Return type of the enclosing function declaring the
contract if that function is either a virtual public
function or a public function override.
Otherwise, this type is always @c void.
contract if that is either a virtual or an
overriding public function, otherwise this is always
@c void.
(Usually this template parameter is automatically
deduced by C++ and it does not need to be explicitly
specified by programmers.)
*/
template<typename VirtualResult = void>
class specify_postcondition_except { // Privately copyable (as *).
@@ -269,11 +278,11 @@ public:
/**
Destruct this object.
@b Throws: This can throw in case programmers specify failure handlers that
throw exceptions instead of terminating the program (see
@b Throws: This is declared @c noexcept(false) since C++11 to allow users
to program failure handlers that throw exceptions on contract
assertion failures (not the default, see
@RefSect{advanced.throw_on_failures__and__noexcept__,
Throw on Failure}).
(This is declared @c noexcept(false) since C++11.)
*/
~specify_postcondition_except() BOOST_NOEXCEPT_IF(false) {}
@@ -281,7 +290,7 @@ public:
Allow to specify postconditions.
@param f Functor called by this library to check postconditions
@c f(...).
@c f() or @c f(result).
Assertions within this functor are usually programmed using
@RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a
call to this functor indicates a contract assertion failure (and
@@ -289,18 +298,25 @@ public:
@RefFunc{boost::contract::postcondition_failure}).
This functor should capture variables by (constant) references
(to access the values they will have at function exit).
This functor must be a nullary functor if @c VirtualResult is
@c void, otherwise it must be a unary functor accepting the
return value as a parameter of type <c>VirtualResult const&</c>
(to avoid extra copies of the return value, or of type
@c VirtualResult or <c>VirtualResult const</c> if extra copies
of the return value are irrelevant).
This functor must be a nullary functor @c f() if
@c VirtualResult is @c void, otherwise it must be a unary
functor @c f(result) accepting the return value @c result as a
parameter of type <c>VirtualResult const&</c> (to avoid extra
copies of the return value, or of type @c VirtualResult or
<c>VirtualResult const</c> if extra copies of the return value
are irrelevant).
@return After postconditions have been specified, the object returned by
this function allows to optionally specify exception guarantees.
*/
template<typename F>
specify_except postcondition(F const& f) {
specify_except postcondition(
F const&
#if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
f
#endif // Else, no name (avoid unused param warning).
) {
BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_
}
@@ -321,9 +337,13 @@ public:
by this function does not allow to specify any additional contract.
*/
template<typename F>
specify_nothing except(F const& f) {
BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_
}
specify_nothing except(
F const&
#if !defined(BOOST_CONTRACT_NO_EXCEPTS) || \
defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
f
#endif // Else, no name (avoid unused param warning).
) { BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ }
/** @cond */
private:
@@ -342,23 +362,26 @@ private:
};
/**
Allow to specify old value copies at body, postconditions, and exception
Allow to specify old values copied at body, postconditions, and exception
guarantees.
Allow to specify functors this library will call to copy old value at body,
Allow to specify functors this library will call to copy old values at body,
check postconditions, and check exception guarantees.
This object is internally constructed by this library when users specify
This object is internally constructed by the library when users specify
contracts calling @RefFunc{boost::contract::function} and similar functions
(that is why this class does not have a public constructor).
@see @RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body},
@see @RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body},
@RefSect{tutorial.postconditions, Postconditions},
@RefSect{tutorial.exception_guarantees, Exception Guarantees}
@tparam VirtualResult Return type of the enclosing function declaring the
contract if that function is either a virtual public
function or a public function override.
Otherwise, this type is always @c void.
contract if that is either a virtual or an
overriding public function, otherwise this is always
@c void.
(Usually this template parameter is automatically
deduced by C++ and it does not need to be explicitly
specified by programmers.)
*/
template<typename VirtualResult = void>
class specify_old_postcondition_except { // Privately copyable (as *).
@@ -366,20 +389,20 @@ public:
/**
Destruct this object.
@b Throws: This can throw in case programmers specify failure handlers that
throw exceptions instead of terminating the program (see
@b Throws: This is declared @c noexcept(false) since C++11 to allow users
to program failure handlers that throw exceptions on contract
assertion failures (not the default, see
@RefSect{advanced.throw_on_failures__and__noexcept__,
Throw on Failure}).
(This is declared @c noexcept(false) since C++11.)
*/
~specify_old_postcondition_except() BOOST_NOEXCEPT_IF(false) {}
/**
Allow to specify old value copies at body.
Allow to specify old values copied at body.
It should often be sufficient to initialize old value pointers as soon as
they are declared, without using this function (see
@RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body}).
@RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body}).
@param f Nullary functor called by this library @c f() to assign old
value copies just before the body is executed but after entry
@@ -395,12 +418,18 @@ public:
value expressions can be captured by (constant) value, or better
by (constant) reference to avoid extra copies).
@return After old value copies at body have been specified, the object
@return After old values copied at body have been specified, the object
returned by this function allows to optionally specify
postconditions and exception guarantees.
*/
template<typename F>
specify_postcondition_except<VirtualResult> old(F const& f) {
specify_postcondition_except<VirtualResult> old(
F const&
#if !defined(BOOST_CONTRACT_NO_OLDS) || \
defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
f
#endif // Else, no name (avoid unused param warning).
) {
BOOST_CONTRACT_SPECIFY_OLD_IMPL_
}
@@ -408,7 +437,7 @@ public:
Allow to specify postconditions.
@param f Functor called by this library to check postconditions
@c f(...).
@c f() or @c f(result).
Assertions within this functor are usually programmed using
@RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a
call to this functor indicates a contract assertion failure (and
@@ -416,18 +445,25 @@ public:
@RefFunc{boost::contract::postcondition_failure}).
This functor should capture variables by (constant) references
(to access the values they will have at function exit).
This functor must be a nullary functor if @c VirtualResult is
@c void, otherwise it must be a unary functor accepting the
return value as a parameter of type <c>VirtualResult const&</c>
(to avoid extra copies of the return value, or of type
@c VirtualResult or <c>VirtualResult const</c> if extra copies
of the return value are irrelevant).
This functor must be a nullary functor @c f() if
@c VirtualResult is @c void, otherwise it must be a unary
functor @c f(result) accepting the return value @c result as a
parameter of type <c>VirtualResult const&</c> (to avoid extra
copies of the return value, or of type @c VirtualResult or
<c>VirtualResult const</c> if extra copies of the return value
are irrelevant).
@return After postconditions have been specified, the object returned by
this function allows to optionally specify exception guarantees.
*/
template<typename F>
specify_except postcondition(F const& f) {
specify_except postcondition(
F const&
#if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
f
#endif // Else, no name (avoid unused param warning).
) {
BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_
}
@@ -448,9 +484,13 @@ public:
by this function does not allow to specify any additional contract.
*/
template<typename F>
specify_nothing except(F const& f) {
BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_
}
specify_nothing except(
F const&
#if !defined(BOOST_CONTRACT_NO_EXCEPTS) || \
defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
f
#endif // Else, no name (avoid unused param warning).
) { BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ }
/** @cond */
private:
@@ -474,24 +514,27 @@ private:
};
/**
Allow to specify preconditions, old value copies at body, postconditions, and
Allow to specify preconditions, old values copied at body, postconditions, and
exception guarantees.
Allow to specify functors this library will call to check preconditions, copy
old values at body, check postconditions, and check exception guarantees.
This object is internally constructed by this library when users specify
This object is internally constructed by the library when users specify
contracts calling @RefFunc{boost::contract::function} and similar functions
(that is why this class does not have a public constructor).
@see @RefSect{tutorial.preconditions, Preconditions},
@RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body},
@RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body},
@RefSect{tutorial.postconditions, Postconditions},
@RefSect{tutorial.exception_guarantees, Exception Guarantees}
@tparam VirtualResult Return type of the enclosing function declaring the
contract if that function is either a virtual public
function or a public function override.
Otherwise, this type is always @c void.
contract if that is either a virtual or an
overriding public function, otherwise this is always
@c void.
(Usually this template parameter is automatically
deduced by C++ and it does not need to be explicitly
specified by programmers.)
*/
template<
typename VirtualResult /* = void (already in fwd decl from decl.hpp) */
@@ -504,11 +547,11 @@ public:
/**
Destruct this object.
@b Throws: This can throw in case programmers specify failure handlers that
throw exceptions instead of terminating the program (see
@b Throws: This is declared @c noexcept(false) since C++11 to allow users
to program failure handlers that throw exceptions on contract
assertion failures (not the default, see
@RefSect{advanced.throw_on_failures__and__noexcept__,
Throw on Failure}).
(This is declared @c noexcept(false) since C++11.)
*/
~specify_precondition_old_postcondition_except() BOOST_NOEXCEPT_IF(false) {}
@@ -526,20 +569,26 @@ public:
better by (constant) reference (to avoid extra copies).
@return After preconditions have been specified, the object returned by this
function allows to optionally specify old value copies at body,
function allows to optionally specify old values copied at body,
postconditions, and exception guarantees.
*/
template<typename F>
specify_old_postcondition_except<VirtualResult> precondition(F const& f) {
specify_old_postcondition_except<VirtualResult> precondition(
F const&
#if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \
defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
f
#endif // Else, no name (avoid unused param warning).
) {
BOOST_CONTRACT_SPECIFY_PRECONDITION_IMPL_
}
/**
Allow to specify old value copies at body.
Allow to specify old values copied at body.
It should often be sufficient to initialize old value pointers as soon as
they are declared, without using this function (see
@RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body}).
@RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body}).
@param f Nullary functor called by this library @c f() to assign old
value copies just before the body is executed but after entry
@@ -555,12 +604,18 @@ public:
value expressions can be captured by (constant) value, or better
by (constant) reference to avoid extra copies).
@return After old value copies at body have been specified, the object
@return After old values copied at body have been specified, the object
returned by this functions allows to optionally specify
postconditions and exception guarantees.
*/
template<typename F>
specify_postcondition_except<VirtualResult> old(F const& f) {
specify_postcondition_except<VirtualResult> old(
F const&
#if !defined(BOOST_CONTRACT_NO_OLDS) || \
defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
f
#endif // Else, no name (avoid unused param warning).
) {
BOOST_CONTRACT_SPECIFY_OLD_IMPL_
}
@@ -568,7 +623,7 @@ public:
Allow to specify postconditions.
@param f Functor called by this library to check postconditions
@c f(...).
@c f() or @c f(result).
Assertions within this functor are usually programmed using
@RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a
call to this functor indicates a contract assertion failure (and
@@ -576,18 +631,25 @@ public:
@RefFunc{boost::contract::postcondition_failure}).
This functor should capture variables by (constant) references
(to access the values they will have at function exit).
This functor must be a nullary functor if @c VirtualResult is
@c void, otherwise it must be a unary functor accepting the
return value as a parameter of type <c>VirtualResult const&</c>
(to avoid extra copies of the return value, or of type
@c VirtualResult or <c>VirtualResult const</c> if extra copies
of the return value are irrelevant).
This functor must be a nullary functor @c f() if
@c VirtualResult is @c void, otherwise it must be a unary
functor @c f(result) accepting the return value @c result as a
parameter of type <c>VirtualResult const&</c> (to avoid extra
copies of the return value, or of type @c VirtualResult or
<c>VirtualResult const</c> if extra copies of the return value
are irrelevant).
@return After postconditions have been specified, the object returned by
this function allows to optionally specify exception guarantees.
*/
template<typename F>
specify_except postcondition(F const& f) {
specify_except postcondition(
F const&
#if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \
defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
f
#endif // Else, no name (avoid unused param warning).
) {
BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_
}
@@ -608,9 +670,13 @@ public:
by this function does not allow to specify any additional contract.
*/
template<typename F>
specify_nothing except(F const& f) {
BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_
}
specify_nothing except(
F const&
#if !defined(BOOST_CONTRACT_NO_EXCEPTS) || \
defined(BOOST_CONTRACT_DETAIL_DOXYGEN)
f
#endif // Else, no name (avoid unused param warning).
) { BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ }
/** @cond */
private:

View File

@@ -39,11 +39,21 @@ functions (for subcontracting).
Virtual public functions (and therefore also public function overrides)
declaring contracts using this library must specify an extra function parameter
at the very end of the parameter list.
at the very end of their parameter list.
This parameter must be a pointer to this class and it must have default value
@c 0 (i.e., @c nullptr).
(This extra parameter is often named @c v in this documentation, but any name
can be used.)
@c 0 or @c nullptr (this extra parameter is often named @c v in this
documentation, but any name can be used):
@code
class u {
public:
virtual void f(int x, boost::contract::virtual_* v = 0) { // Declare `v`.
... // Contract declaration (which will use `v`) and function body.
}
...
};
@endcode
In practice this extra parameter does not alter the calling interface of the
enclosing function declaring the contract because it is always the very last