Boost logo

Boost Users :

Subject: Re: [Boost-users] circular_buffer, debug and invalid iterator checking
From: Jan Gaspar (jano_gaspar_at_[hidden])
Date: 2010-11-19 05:30:03


You can achieve the same by relying on #if defined(NDEBUG) || defined(BOOST_CB_DISABLE_DEBUG) ... #else ... #endif Jan ________________________________ From: Anthony Foglia <AFoglia_at_[hidden]> To: boost-users_at_[hidden] 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_at_[hidden] http://lists.boost.org/mailman/listinfo.cgi/boost-users



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net