boost::excessive_syntax

Apologies to the majority of people who have no idea what this is about.

class YourBrain
{
public:
      YourBrain();
      virtual ~YourBrain();
 
      YourBrain* Get()
      {
            return this;
      }
 
      static YourBrain* Create()
      {
            return new YourBrain();
      }
};
 
class YourBrainDerived : public YourBrain
{
public:
      YourBrainDerived *Get()
      {
            return this;
      }
 
      static YourBrainDerived* Create()
      {
            return new YourBrainDerived();
      }
};
 
std::vector<YourBrain *> GetListOfYourBrain()
{
      std::vector<YourBrain *> oList;
      oList.push_back(YourBrain::Create());
      oList.push_back(YourBrainDerived::Create());
      return oList;
}
 
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
 
class YourBrainOnSharedPointers : public boost::enable_shared_from_this<YourBrainOnSharedPointers>
{
public:
      YourBrainOnSharedPointers();
      virtual ~YourBrainOnSharedPointers();
 
      boost::shared_ptr<YourBrainOnSharedPointers> Get()
      {
            return shared_from_this();
      }
 
      static boost::shared_ptr<YourBrainOnSharedPointers> Create()
      {
            return boost::shared_ptr<YourBrainOnSharedPointers>(new YourBrainOnSharedPointers());
      }
};
 
class YourBrainOnSharedPointersDerived : public YourBrainOnSharedPointers
{
public:
      boost::shared_ptr<YourBrainOnSharedPointersDerived> Get()
      {
            return boost::dynamic_pointer_cast<YourBrainOnSharedPointersDerived>(shared_from_this());
      }
 
      static boost::shared_ptr<YourBrainOnSharedPointersDerived> Create()
      {
            return boost::shared_ptr<YourBrainOnSharedPointersDerived>(new YourBrainOnSharedPointersDerived());
      }
};
 
std::vector<boost::shared_ptr<YourBrainOnSharedPointers> > GetListOfYourBrainOnSharedPointers()
{
      std::vector<boost::shared_ptr<YourBrainOnSharedPointers>> oList;
      oList.push_back(boost::shared_ptr<YourBrainOnSharedPointers>(YourBrainOnSharedPointers::Create()));
      oList.push_back(boost::shared_ptr<YourBrainOnSharedPointersDerived>(YourBrainOnSharedPointersDerived::Create()));
      return oList;
}

Any Questions?

(If the post just looks like an unreadable pile of punctuation, that's kind of the point).