Skip to content

Latest commit

 

History

History
40 lines (23 loc) · 1.27 KB

CppBoostPtr_set.md

File metadata and controls

40 lines (23 loc) · 1.27 KB

 

 

 

 

 

 

boost::ptr_set is a container for storing pointers that behaves a std::set. boost::ptr_set will delete all stored pointers when it goes out of scope.

 


#include <boost/ptr_container/ptr_set.hpp> struct MyClass {   MyClass(const int x = 0) : mX(x) {}   const int mX; }; bool operator<(const MyClass lhs, const MyClass rhs) {   return lhs.mX < rhs.mX; } int main() {   boost::ptr_set<MyClass> s;   s.insert(new MyClass); }