27 typedef std::unique_ptr<ObjT> SmartPtr;
28 std::queue<ObjT*> free_obj_list_;
29 std::vector<SmartPtr> allocated_objs_;
35 template<
typename... Args>
36 ObjT * create(Args&&... args)
39 if(free_obj_list_.empty()) {
40 allocated_objs_.emplace_back(
new ObjT(args...));
41 obj = allocated_objs_.back().get();
44 obj = free_obj_list_.front();
52 void free(ObjT * obj) {
53 free_obj_list_.push(obj);
57 allocated_objs_.clear();
58 free_obj_list_ = std::queue<ObjT *>();