Boost logo

Boost :

From: John Torjo (john_at_[hidden])
Date: 2003-06-02 08:39:35


Hi all,

Another smart_assert update:
* SMART_ENFORCE works, very much like SMART_VERIFY/ SMART_ASSERT
  (see example: enforce.cpp)
  Works much like in Andrei Alexandrescu's article.
* multiple configurations: a lot easier to manage
* assert_context_func - redone, much easier to use now.
* handler for Win32 (when an assertion fails, asks the user what to do by
showing a dialog with buttons: Ignore/Ignore Forever/Ignore
All/Debug/Abort/More details).
  It's pretty basic for now. Comments are welcome!
* minor improvements.

You can also get it from:
www.torjo.com/smart_assert.zip

About enforcements:
Now, they behave much like SMART_ASSERTs.
This means that if an ENFORCE fails, it will be treated like an ASSERT,
meaning that it will be logged.

Example:
// this will throw an error, if _read fails.
const int available =
    HANDLE_ENFORCE(_read(file, buffer, buflen))(file)(buffer)(buflen)
        .msg( "could not read from file");

However, I assume that you use ENFORCE when you expect that an expression
might be invalid. Since you're expecting this, it might not be such a good
idea to log the fact that this failed - throwing an error will probably be
enough.

I was thinking of implementing something like:
Allow enabling/disabling of logging for certain ASSERT levels.
For instance, something similar to
assert_settings().enable_level( lvl_enforce, false);
would turn off logging for SMART_ENFORCEs.

What do you think?

I'll be working on the documentation the following days.

--
John Torjo
-- "Practical C++" column writer for builder.com.com
Freelancer, C++ consultant
mailto:john_at_[hidden]



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