#include #include namespace bi=boost::intrusive; class Item : public bi::unordered_set_base_hook> { public: struct hash { size_t operator()(const Item &s) const { return /* ... */ 0; } }; }; void main() { typedef bi::unordered_set< Item, bi::constant_time_size, bi::hash > map_type; std::unique_ptr buckets; std::unique_ptr set; buckets.reset(new map_type::bucket_type[50]); set.reset(new map_type(map_type::bucket_traits(buckets.get(),50))); // ... use the set set->clear_and_dispose([](Item *ptr) { delete ptr; }); }