Definition of ::DBC1<..>::operator()(..).

Supporting Design by Contract in C++
by David Maley and Ivor Spence
Listing 3. Definition of ::DBC1<..>::operator()(..).

template <typename Object, typename ReturnType,
     typename Formal1>
ReturnType DBC1<Object, ReturnType, Formal1>::operator()(const Formal1& t1)
    if (!_object->invariant())
      throw Object(*_object);
    if (!pre(t1))
    _old = new Object(*_object);
    ReturnType result=(_mutableObject->*_body)(t1);
    if (!post(result, t1))
    if (!_object->invariant())
      throw Object(*_object);
    return result;

About the Authors

David Maley is with St. Mary's University College, Belfast. He can be contacted at [email protected].

Ivor Spence is with Queen's University of Belfast. He can be contacted at [email protected].

Upcoming Events