Boost logo

Boost :

From: D'Alessio, George (george.d'alessio_at_[hidden])
Date: 2002-10-28 10:15:47

        An interesting work was presented by David Maley
(d.maley_at_[hidden]) and Ivor Spence (i.spence_at_[hidden])for the
1999 Technology of Object-Oriented Languages and Systems conference. The
abstract follows. Hope it helps.

To date, much of the software written in Computational Physics has been
produced with little regard paid to modern software engineering techniques;
this paper documents experiences in beginning to address this shortcoming
for Config, a component of the Graphical R-Matrix Atomic Collision
Environment (GRACE). The work is based around a formal specification of the
Config component. The principal focus of the paper will be on a
non-intrusive mechanism for monitoring constraints such as class invariants,
preconditions and postconditions for highly structured data types based on
the containers and algorithms of the Standard Template Library (STL), a
mechanism which can be extended to handle structured object update and
display prototyping.

-----Original Message-----
From: Martin [mailto:m_at_[hidden]]
Sent: Sunday, October 27, 2002 1:50 AM
To: boost_at_[hidden]
Subject: [boost] Programming by contract


Does anybody have any ideas or pointers to how programming by contract can
be implemented easily in C++? I can only think of one non-elegant solution
which involves defining a class in the function that is derived from a
template class. something like this (not fully implemented):

namespace boost
    template<class result_type>
    class contract
        result_type run()
            result_type res = body();
            return res;
        virtual void precondition() {};
        virtual void postcondition() {};
        virtual result_type body(argument_type arg) = 0;

int foo()
    class MyImplementation : public boost::contract<int>
        void body()
            // here put your own code
        // here define a postcondition
        void postcondition()
            // always fail our postconditions
            BOOST_ASSERT(true == false);

    MyImplementation anImpl;

This example does not handle any arguments for the function. Anyway, I would
appreciate any comments or ideas on this topic.

Regards, Martin Bosticky.

Unsubscribe & other changes:

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