Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) boost::ptr_set

 

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);
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict