Boost logo

Boost :

Subject: Re: [boost] Boost.Exception and constexpr
From: Peter Dimov (lists_at_[hidden])
Date: 2013-01-10 12:19:28


> constexpr const_reference operator[]( size_type i ) const
> {
> return BOOST_CONSTEXPR_ASSERT( i < size(), elems[i] );
> }

The following, more intuitive, might also work:

constexpr const_reference operator[]( size_type i ) const
{
    return BOOST_ASSERT(i < size()), elems[i];
}

There was some disagreement about the comma expression, but it looks like
it's allowed. Most definitions of `assert` (to which BOOST_ASSERT maps
usually) should also be fine, even though this is not presently guaranteed
by the standard.

BOOST_ASSERT_MSG does not depend on the definition of `assert` at all, so it
should also work.


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