#include #include #include #include using namespace boost::interprocess; typedef segment_deleter shared_segment_deleter; /* Why, by the way, I must specialize segment_deleter by defining 'pointer' type? Bug? */ template class SegmentDeleter : public shared_segment_deleter { public: typedef T *pointer; SegmentDeleter(SegmentManagerPtr mngr) : shared_segment_deleter(mngr) {} }; class Class { }; typedef allocator Allocator; typedef shared_ptr > SharedPtr; int main() { managed_shared_memory shared_segment( create_only, "shared_segment", 65536); managed_shared_memory::segment_manager * segment_manager = shared_segment.get_segment_manager(); Allocator alloc(segment_manager); SegmentDeleter deleter(segment_manager); Class * obj = shared_segment.construct(anonymous_instance)(); SharedPtr * ptr = shared_segment.construct(anonymous_instance)(obj, alloc, deleter); return 0; }