Boost logo

Boost :

Subject: Re: [boost] [utility] [assert] Proposal for a new assert macro which stores the failed values ("informative assert")
From: Viktor Sehr (viktor.sehr_at_[hidden])
Date: 2013-06-07 06:21:17


>
> My motivation comes from using boost::array::operator[]:
>
> reference operator[](size_type i)
> {
> BOOST_ASSERT_MSG( i < N, "out of range" );
> return elems[i];
> }
>
> I experienced problems with this function, which Andrey described above.
> And my proposition of simplifying BOOST_ASSERT_MSG would work around this,
> but I didn't think of more complicated use cases.
>
> So should there be a guideline to use the BOOST_ASSERT( expr || !"msg" )
> idiom instead of BOOST_ASSERT_MSG, when msg is only a string literal, or
> how should this problem be addressed?
>
>
You could use regular boost assert as: BOOST_ASSERT(i < N && "out of
range"); as you dont serialize any variables.


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