You can achieve the same by relying on
#if defined(NDEBUG) || defined(BOOST_CB_DISABLE_DEBUG)
...
#else
...
#endif

Jan


From: Anthony Foglia <AFoglia@princeton.com>
To: boost-users@lists.boost.org
Sent: Wed, 17 November, 2010 21:40:45
Subject: Re: [Boost-users] circular_buffer, debug and invalid iterator checking

Still working on my circular_buffer iterator invalidation problems, and another issue arose.  As I mentioned before my class is roughly

class MyContainer {
  private:
    circular_buffer<T> my_buffer;
    vector<circular_buffer<T>::const_iterator> my_range_ends;
  // omitted
}

I'm trying to add a swap method, and the obvious approach does not work:

void MyContainter::swap(MyContainer & other) {
    using std::swap;
    swap(my_buffer, other.my_buffer);
    swap(my_range_ends, other.my_range_ends);
}

This is unsurprising, because of the iterator invalidation rules.  So I'll need to manually figure out the distances and create temporary vectors to hold my_range_ends.  But this just seems like too much trouble if I'm not in debug mode.  If the BOOST_CB_ENABLE_DEBUG macro hadn't been undefined by circular_buffer.hpp I could wrap my hand-coded iterator swapping in #if...#endif, and otherwise just use std::swap.

I think this is a valid use case for leaving that macro defined.  Any reasons I should not file a ticket requesting the change?

-- Anthony Foglia
Princeton Consultants
(609) 987-8787 x233

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users