Boost logo

Boost :

Subject: Re: [boost] [contract] Contract Programming Library
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2010-02-16 15:01:52


Hi,
two other questions that came to my mind, regarding the library design.

(1)
Sometimes the assertions execute longer than the function itself. For example:

        iterator find( iterator begin, iterator end, value v )
        precondition { is_sorted( begin, end ); }
        {
                return find_sorted( begin, end, v );
        }
        
find_sorted has logarithmic complexity, whereas is_sorted has linear
one. If I use function find like this:

        sort( begin, end );
        process( find(begin, end, A) ); // call is_sorted
        process( find(begin, end, B) ); // call is_sorted
        process( find(begin, end, C) ); // call is_sorted

is_sorted is called many a time. Even if I am in debugging mode but
use a medium size range, the performance can kill me. I would like to
disable checking of this assertion, but at the same time there is no
reason to disable others. Would you consider providing a way to
selectively disable asserts? some assertion level?

(2).
Usually public member functions would be used to express DbC
assertions. Do you disable assertions in public functions that are
called only to evaluate other assertions in order to avoid recursive
calls?

Regards,
&rzej


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk