Boost logo

Boost :

From: D language (mbosticky_at_[hidden])
Date: 2002-10-28 08:48:14

>Good points. Perhaps there should be two functions to check
>postconditions. One in case of an exception, one without. That would be
>easy to implement, but what if a range of exceptions can be thrown and
>the postconditions are different in each case? A try catch block with
>different post condition checks in each catch?
>I'm beginning to believe that this is alot harder than I first thought. ;)

Yes. That would just be too complex and you could end up with bugs in the
postcondition code too easily.

It seems to me that only way to implement pre/post conditions is to use
class objects. I suppose we have kind of established that one. Just had an
idea that perhaps instead of functions, in a class, one could write (scoped)
functors that would behave like functions.

class MyClass
    class FnSetMyParameter()
        MyClass& rObject;
        FnSetMyParameter(MyClass& myObject) : rObject(myObject) { }
        void operator()(int x)

MyClass aClass;
int x = 34;

This class could then be devoted totally to the function and in theory could
handle all sorts of strange behaviour that we are talking about. Only
drawback would be that overriding functions would go out the window. At
least i am not aware how this could be done (if at all).

PS: name "D language" was a mistake, it is still me, Martin

>Unsubscribe & other changes:

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