Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the master branch, built from commit 97da996172.
PrevUpHomeNext

Macro BOOST_CONTRACT_PRECONDITION

BOOST_CONTRACT_PRECONDITION — Program preconditions that can be completely disabled at compile-time.

Synopsis

// In header: <boost/contract_macro.hpp>

BOOST_CONTRACT_PRECONDITION(...)

Description

BOOST_CONTRACT_PRECONDITION(f) expands to code equivalent to the following (note that no code is generated when BOOST_CONTRACT_NO_PRECONDITIONS is defined):

#ifndef BOOST_CONTRACT_NO_PRECONDITIONS
    .precondition(f)
#endif

Where:

  • f is the nullay functor called by this library to check preconditions f(). Assertions within this functor are usually programmed using BOOST_CONTRACT_ASSERT, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling boost::contract::precondition_failure). This functor should capture variables by (constant) value, or better by (constant) reference (to avoid extra copies). (This is a variadic macro parameter so it can contain commas not protected by round parenthesis.)

See Also:

Disable Contract Compilation, Preconditions


PrevUpHomeNext