Opened 8 years ago

Last modified 7 years ago

#10543 new Bugs

circular_buffer::rotate() incorrectly assumes that circular_buffer::pointer is a simple pointer type

Reported by: Matteo Settenvini <matteo.settenvini@…> Owned by: Jan Gaspar
Milestone: To Be Determined Component: circular_buffer
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc:

Description

Dear maintainer,

I am trying to use a boost::circular_buffer inside a shared memory segment, along with Boost.Interprocess. This implies that the type of the stored pointer is an offset_ptr<T>, and not just a T *.

In circular_buffer/base.hpp, the rotate method uses a const_cast from the member of a const iterator, assuming that "pointer" is indeed a simple pointer type. This however fails when it is instead a structure, such as boost::interprocess::offset_ptr<T>.

The patch I am attaching below solves the issue for me, by allowing the right template specialization to kick in. I did not test it with different pointer types as I am a bit short on time, but by reading the code alone, it should work also with plain pointers.

Attachments (1)

002-circular-buffer-const_cast-generalization.patch (686 bytes ) - added by Matteo Settenvini <matteo.settenvini@…> 8 years ago.
Use boost::intrusive::pointer_traits to specialize the const_cast on the pointer type.

Download all attachments as: .zip

Change History (3)

by Matteo Settenvini <matteo.settenvini@…>, 8 years ago

Use boost::intrusive::pointer_traits to specialize the const_cast on the pointer type.

comment:1 by anonymous, 8 years ago

Please apply the patch to the trunk.

comment:2 by matteo.settenvini@…, 7 years ago

Any chance of getting this in before 1.60 is released?

Note: See TracTickets for help on using tickets.