Function template public_function
boost::contract::public_function — Program contracts for void public functions overrides (virtual or not). 
 
Synopsis
Description
This is used to specify preconditions, postconditions, exception guarantees, old value copies at body, and check class invariants for public function overrides (virtual or not) that return void: 
class u
    #define BASES private boost::contract::constructor_precondition<u>, \
            public b, private w
    : BASES
{
    friend class boost::contract::access;
    typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
    #undef BASES
    void invariant() const { 
        BOOST_CONTRACT_ASSERT(...);
        ...
    }
    BOOST_CONTRACT_OVERRIDES(f)
public:
    
    void f(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) {
        boost::contract::old_ptr<old_type> old_var;
        boost::contract::check c = boost::contract::public_function<
                override_f>(v, &u::f, this, a_1, ..., a_n)
            .precondition([&] { 
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .old([&] { 
                old_var = BOOST_CONTRACT_OLDOF(v, old_expr);
                ...
            })
            .postcondition([&] { 
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
            .except([&] { 
                BOOST_CONTRACT_ASSERT(...);
                ...
            })
        ;
        ... 
    }
    
    ...
};
A public function override should always call  boost::contract::public_function
See Also:
 
        Public Function Overrides
| Parameters: | 
| args
 | All arguments passed to the enclosing public function override declaring the contract (by reference and in the order they appear in the enclosing function declaration), but excluding the trailing argument v. |  
| f
 | A pointer to the enclosing public function override declaring the contract (but see 
            Function Overloads).  |  
| obj
 | The object thisfrom the scope of the enclosing public function override declaring the contract. This object might be mutable,const,volatile, orconst volatiledepending on the cv-qualifier of the enclosing function (volatile public functions will check volatile class invariants, see  
            Volatile Public Functions). |  
| v
 | The trailing parameter of type  boost::contract::virtual_*and default value0from the enclosing public function override. |  | 
| Template Parameters: | 
| Args
 | The types of all parameters passed to the enclosing public function override declaring the contract, but excluding the trailing parameter type . On compilers that do not support variadic templates, this library internally implements this function using preprocessor meta-programming (in this case, the maximum number of supported arguments is defined byboost::contract::virtual_*). (Usually these template parameters are automatically deduced by C++ and they do not need to be explicitly specified by programmers.)BOOST_CONTRACT_MAX_ARGS |  
| Class
 | The type of the class containing the virtual public function declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)  |  
| F
 | The function pointer type of the enclosing public function override declaring the contract. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.)  |  
| Override
 | The type trait override_function-namedeclared using theor related macros. This template parameter must be explicitly specified (because there is no function argument from which it can be automatically deduced by C++).BOOST_CONTRACT_OVERRIDE |  | 
| Returns: | The result of this function must be assigned to a variable of type  boost::contract::checkdeclared explicitly (i.e., without using C++11autodeclarations) and locally just before the code of the public function body (otherwise this library will generate a run-time error, seeBOOST_CONTRACT_ON_MISSING_CHECK_DECL). |