Boost logo

Boost :

Subject: Re: [boost] [Serialization] can BOOST_ASSERT have method calls?
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2011-01-18 09:18:42

Jeff Flinn wrote:
> Patrick Horgan wrote:
>> I noticed in serializations basic_iarchive that when you're not
>> building for debug the next line here (317 in basic_iarchive.cpp) has
>> a warning for unused variable new_cid. The BOOST_ASSERT is
>> instantiated as ((void)0) so new_cid really isn't used. Could the
>> register_type call be moved into the assert?
>> class_id_type new_cid =
>> register_type(bpis_ptr->get_basic_serializer());
>> int i = cid;
>> cobject_id_vector[i].bpis_ptr = bpis_ptr;
>> BOOST_ASSERT(new_cid == cid);
>> Something like:
>> BOOST_ASSERT(register_type(bpis_ptr->get_basic_serializer())
>> == cid);
> IIRC, register_type would not be called in release builds. MSFT had a
> VERIFY macro which asserted in debug, and still executed the statement
> in release builds. Or am I mistaken about BOOST_ASSERT's implementation?

Looks like there already is BOOST_VERIFY. So

BOOST_VERIFY(register_type(bpis_ptr->get_basic_serializer()) == cid);

Would do the right thing in both release and debug builds, as well as


Boost list run by bdawes at, gregod at, cpdaniel at, john at