Boost logo

Boost :

Subject: [boost] [contract] relaxing preconditions in subcontracting
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2012-06-12 07:43:50

Hi Lorenzo,
I am trying to understand how the feature of relaxing preconditions in
overridden functions work or should work. Given the situation, where I call
an overridden function via base class reference:

*struct Base
  virtual void fun(bool b) = 0 precondition{ b == true };

struct Deriv : Base
  void fun(bool b) override precondition{ true };

void test( Base & b )
{; **// broken contract or not?**

Should this be treated as a broken contract or not? My reading of the
documentation says that contract is not broken (because the
logic applies), but I feel that whoever implemented function *test *made a
mistake: he cannot assume what type will be implementing "interface" *Base*,
so he cannot rely on the precondition being relaxed (even if he gets away
with it this time).


Boost list run by bdawes at, gregod at, cpdaniel at, john at