#8976 closed Bugs (fixed)
interprocess::shared_ptr fails to compile if used with a scoped_allocator
| Reported by: | Owned by: | Ion Gaztañaga | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | interprocess |
| Version: | Boost 1.54.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
The following code will fail to compile using at least gcc 4.6.3
#include <memory>
#include <boost/container/scoped_allocator.hpp>
#include <boost/interprocess/smart_ptr/shared_ptr.hpp>
namespace bip=boost::interprocess;
int main(int argc, char* argv[]) {
class MyDeleter {
public:
typedef std::allocator<void>::pointer pointer;
void operator()(const pointer& ptr){};
};
typedef boost::container::scoped_allocator_adaptor< std::allocator<void> > Allocator;
Allocator alloc;
// next line will fail to compile due to a inaccessible base type error
bip::shared_ptr<int,Allocator::outer_allocator_type,MyDeleter> test1(new int(),alloc);
//using the outer_allocator will work fine
bip::shared_ptr<int,Allocator::outer_allocator_type,MyDeleter> test2(new int(),alloc);
};
Attachments (1)
Change History (6)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Another workaround ist to use:
boost::interprocess:shared_ptr<int,container::outermost_allocator<Allocator>::type,MyDeleter>
to remove the scoped allocator capabilities which anyway are not needed ...
comment:3 by , 9 years ago
Thanks for the report, the problem was in the "destroy" function, where a proper static_cast was needed.
Note:
See TracTickets
for help on using tickets.

Typo while copying the code. The line to fail must read: