Re: [boost] [circular-buffer] indexes

Yes, using the modulus operation would do. But I think wrapping the circular_buffer instead of deriving from it would suit better as there is no virtual destructor present in the circular_buffer. ----- Original Message ---- From: Neal Becker <ndbecker2@gmail.com> To: boost@lists.boost.org Sent: Monday, 7 April, 2008 2:25:20 PM Subject: [boost] [circular-buffer] indexes I use my own implementation of circular buffers which simulate an infinite buffer that simply wraps around. The indexes are not restricted in either positive or negative direction. This is a very useful construct (believe it or not). It looks like boost::circular_buffer restricts the indexes. I suppose the straightforward way to use boost::circular_buffer would be derive from it and add a modulus operation to the indexing? _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost ___________________________________________________________ Yahoo! For Good helps you make a difference http://uk.promotions.yahoo.com/forgood/

Jan Gaspar <jano_gaspar <at> yahoo.com> writes:
Yes, using the modulus operation would do. But I think wrapping the circular_buffer instead of deriving from it would suit better as there is no virtual destructor present in the circular_buffer.
I think the "don't derive without virtual dtor" rule is a little overrated. I give my opinions on the matter at http://bannalia.blogspot.com/2008/02/derivation-without-virtual-destructor.h... Best regards, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

On reflection, I think the fact that the unneeded bounds checking can't be turned off would probably dissuade me from using this. (I doubt any compiler is going to be smart enough to realize the bounds check following the modulus is unnecessary). Too bad circular-buffer doesn't allow turning off the checking (via a template parameter). Jan Gaspar wrote:
Yes, using the modulus operation would do. But I think wrapping the circular_buffer instead of deriving from it would suit better as there is no virtual destructor present in the circular_buffer.
----- Original Message ---- From: Neal Becker <ndbecker2@gmail.com> To: boost@lists.boost.org Sent: Monday, 7 April, 2008 2:25:20 PM Subject: [boost] [circular-buffer] indexes
I use my own implementation of circular buffers which simulate an infinite buffer that simply wraps around. The indexes are not restricted in either positive or negative direction. This is a very useful construct (believe it or not).
It looks like boost::circular_buffer restricts the indexes. I suppose the straightforward way to use boost::circular_buffer would be derive from it and add a modulus operation to the indexing?
participants (3)
-
Jan Gaspar
-
Joaquin M Lopez Munoz
-
Neal Becker