Boost logo

Boost :

Subject: Re: [boost] [utility] [assert] Proposal for a new assert macro which stores the failed values ("informative assert")
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2013-06-05 11:30:06


On Wed, Jun 5, 2013 at 7:07 PM, Viktor Sehr <viktor.sehr_at_[hidden]> wrote:

> I'd like some opinions about this assert implementation which I'd like to
> propose as an update of the old BOOST_ASSERT.
>
> Basically it stores the failed values next to the expression string,
> instead of just the expression string:
> "INFORMATIVE_ASSERT(5*5 < 2*2);"
> "5*5 < 2*2 | 25 | 4"
>
> "INFORMATIVE_ASSERT(std::vector<int>(10).size() ==
> std::vector<int>(12).size());"
> "std::vector<int>(10).size() > std::vector<int>(12).size() | 10 | 12"
>
>
> Notes
> - If the class can't be serialized, the byte-data is logged instead.
> - It writes the values to the expression string in order to be compliant
> with any assert implementations
>
>
> Easy to read implementation available here:
>
> https://docs.google.com/file/d/0B69BCPzak52DcnF5dmhRRno3V2M/edit?usp=sharing
>
> Modified version of BOOST_ASSERT available here:
>
> https://docs.google.com/file/d/0B69BCPzak52DZW1oX1AtREM4eVU/edit?usp=sharing
>

I would very much prefer BOOST_ASSERT to stay as small and lightweight as
possible and equivalent to the standard assert macro by default. One reason
we're not using BOOST_ASSERT_MSG much is that it uses streaming expressions
to format the error message, which turns out to be too heavy in some places
(e.g. it prevents small functions from inlining and fragments the hot code
too much). Please, make a new macro for this feature.


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