John Torjo wrote: > Hi Michael, > >> >> 1) How is this going? >> > > Unfortunately, I've been EXTREMELY busy these days :( > > It's almost done - I've worked on making a small footprint of > SMART_ASSERT (when using SMART_ASSERT, the generated code should be > as small as possible) > > Note: try the latest version - www.torjo.com/smart_assert.zip > I want to write the full documentation, and then post it to boost > sandbox as well. > >> >> 2) I notice that when the "Debug" button in the Win32 assertion >> dialog is pressed, it breaks into the debugger deep inside >> smart_assert code. Any chance of moving the debug-break out into the >> SMART_ASSERT macro? I > suppose >> this would be done by making the handler return values that specify >> standard actions (do nothing, break into debugger, abort, etc.). > > Hmm. I think it can be done. I'll try these days - hopefully should > do it until Fri. > >> >> 3) I've always wanted an assertion that would evaluate the condition >> and fire when the enclosing block exits instead of immediately >> (i.e., a postcondition). I realize this would have to work in an >> entirely different way from a standard assertion, in that it would >> require the condition to > be >> a boost::bind type function or boost::lambda type expression that >> could be evaluated later. Something like a ScopeGuard that evaluates >> to an assertion, in fact. Do you have any interest in pursuing this? >> I'd be glad to help, > if >> I can. >> > > I'm not quite sure of the usefullness of this. > Please go into more details.
A postcondition such as I'm suggesting would perform an assertion when a function (or the enclosing block) exits instead of on the line where the assertion was defined. Obviously, if a function only has one exit path, it would be simple just to put assertions at the end of the function, but if a function has multiple exit points, this would be inadequate. An example of what I mean is something like this (where SMART_ASSERT_POST is the new postcondition assertion that I'm suggesting): class SomeClass(void) { public: void SomeFunction(void) { //Precondition: check class invariants on function entry SMART_ASSERT(CheckClassInvariants()); //Postcondition: check class invariants on function exit SMART_ASSERT_POST(CheckClassInvariants()); //Function body here } private: bool CheckClassInvariants(void) { //Return true if class invariants are met } }; Another example would be something like this: int SomeFunction(int arg) { //Precondition: check argument on function entry SMART_ASSERT(arg >0 && arg < 10); int result = 0; //Postcondition: check result on function exit SMART_ASSERT_POST(ref(result) >= 0); //Function body here return result; } As far as how it would be implementated, as I suggested before, I assume the post condition would create an object whose destructor asserts the condition when the block the it is defined in exits. Mike > Best, > John > > _______________________________________________ > Unsubscribe & other changes: > http://lists.boost.org/mailman/listinfo.cgi/boost _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost