![]() |
Home | Libraries | People | FAQ | More |
boost::contract::virtual_ — Type of extra function parameter to handle contracts for virtual public functions (for subcontracting).
// In header: <boost/contract/core/virtual.hpp> class virtual_ { };
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 their parameter list. This parameter must be a pointer to this class and it must have default value 0
or nullptr
(this extra parameter is often named v
in this documentation, but any name can be used):
class u { public: virtual void f(int x, boost::contract::virtual_* v = 0) { // Declare `v`. ... // Contract declaration (which will use `v`) and function body. } ... };
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 parameter and it has a default value (so it can always be omitted when users call the function). This extra parameter must be passed to boost::contract::public_function
, BOOST_CONTRACT_OLDOF
, and all other operations of this library that accept a pointer to boost::contract::virtual_
. A part from that, this class is not intended to be directly used by programmers (and that is why this class does not have any public member and it is not copyable).
See Also:
Virtual Public Functions, Public Function Overrides