mirror of
https://github.com/boostorg/contract.git
synced 2026-02-26 16:42:19 +00:00
added .except(...), renamed old_ptr_noncopyable to old_ptr_if_copyable, and renamed OLDOF to OLD
This commit is contained in:
@@ -20,11 +20,11 @@ public:
|
||||
/* Creation */
|
||||
|
||||
observer() {
|
||||
boost::contract::guard c = boost::contract::constructor(this);
|
||||
boost::contract::check c = boost::contract::constructor(this);
|
||||
}
|
||||
|
||||
virtual ~observer() {
|
||||
boost::contract::guard c = boost::contract::destructor(this);
|
||||
boost::contract::check c = boost::contract::destructor(this);
|
||||
}
|
||||
|
||||
/* Commands */
|
||||
@@ -38,13 +38,13 @@ public:
|
||||
};
|
||||
|
||||
bool observer::up_to_date_with_subject(boost::contract::virtual_* v) const {
|
||||
boost::contract::guard c = boost::contract::public_function(v, this);
|
||||
boost::contract::check c = boost::contract::public_function(v, this);
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
void observer::update(boost::contract::virtual_* v) {
|
||||
boost::contract::guard c = boost::contract::public_function(v, this)
|
||||
boost::contract::check c = boost::contract::public_function(v, this)
|
||||
.postcondition([&] {
|
||||
BOOST_CONTRACT_ASSERT(up_to_date_with_subject()); // Up-to-date.
|
||||
})
|
||||
|
||||
@@ -35,20 +35,20 @@ public:
|
||||
// Construct subject with no observer.
|
||||
subject() {
|
||||
// Check invariant.
|
||||
boost::contract::guard c = boost::contract::constructor(this);
|
||||
boost::contract::check c = boost::contract::constructor(this);
|
||||
}
|
||||
|
||||
// Destroy subject.
|
||||
virtual ~subject() {
|
||||
// Check invariant.
|
||||
boost::contract::guard c = boost::contract::destructor(this);
|
||||
boost::contract::check c = boost::contract::destructor(this);
|
||||
}
|
||||
|
||||
/* Queries */
|
||||
|
||||
// If given object is attached.
|
||||
bool attached(observer const* ob) const {
|
||||
boost::contract::guard c = boost::contract::public_function(this)
|
||||
boost::contract::check c = boost::contract::public_function(this)
|
||||
.precondition([&] {
|
||||
BOOST_CONTRACT_ASSERT(ob); // Not null.
|
||||
})
|
||||
@@ -63,8 +63,8 @@ public:
|
||||
// Attach given object as an observer.
|
||||
void attach(observer* ob) {
|
||||
boost::contract::old_ptr<std::vector<observer const*> > old_observers =
|
||||
BOOST_CONTRACT_OLDOF(observers());
|
||||
boost::contract::guard c = boost::contract::public_function(this)
|
||||
BOOST_CONTRACT_OLD(observers());
|
||||
boost::contract::check c = boost::contract::public_function(this)
|
||||
.precondition([&] {
|
||||
BOOST_CONTRACT_ASSERT(ob); // Not null.
|
||||
BOOST_CONTRACT_ASSERT(!attached(ob)); // Not already attached.
|
||||
@@ -102,7 +102,7 @@ protected:
|
||||
// Update all attached observers.
|
||||
void notify() {
|
||||
// Protected members use `function` (no inv and no subcontracting).
|
||||
boost::contract::guard c = boost::contract::function()
|
||||
boost::contract::check c = boost::contract::function()
|
||||
.postcondition([&] {
|
||||
if(O_N <= COMPLEXITY_MAX) {
|
||||
// All updated.
|
||||
@@ -137,7 +137,7 @@ private:
|
||||
observer const* ob
|
||||
) {
|
||||
// Private members use `function` (no inv and no subcontracting).
|
||||
boost::contract::guard c = boost::contract::function()
|
||||
boost::contract::check c = boost::contract::function()
|
||||
.precondition([&] {
|
||||
BOOST_CONTRACT_ASSERT(ob); // Not null.
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user