7 Jun
2013
7 Jun
'13
10:21 a.m.
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.