I'm designing a Factory in C++ with raw pointers, but I'd like to use smart pointers when possible as is recommended with the Factory pattern in newer C++. Unfortunately my compiler is a bit old (gcc 4.4.6) and not all of the features of C++11 (let alone C++0x) are available to me.I cannot use nullptr, which is the most troubling aspect to me. I'd love a standard review and any tips for adding smart pointers to my code.#ifndef SERVICE_FACTORY_H_#define SERVICE_FACTORY_H_#include <string>#include <map>#include <memory>class Service {  public:      virtual void free() = 0;};typedef Service* (*CreationFunction)(void);class Counter : public Service {  public:    static Service* create() { return new Counter(); }    void free() { delete this; }};class ServiceFactory {  public:    ~ServiceFactory() {      _registeredServices.clear();    }    static ServiceFactory* getInstance() {      static ServiceFactory instance;      return &instance;    }    void registerService(const std::string &serviceName, CreationFunction fn) {      _registeredServices[serviceName] = fn;    }    Service* createService(const std::string &serviceName) {      auto it = _registeredServices.find(serviceName);      if(it != _registeredServices.end())        return it->second();      return NULL;    }  private:    ServiceFactory() {      registerService(COUNTER, &Counter::create);    }    ServiceFactory(const ServiceFactory&) { /* Nothing implemented yet */ }    ServiceFactory& operator=(const ServiceFactory&) { return *this; }    std::map<std::string, CreationFunction> _registeredServices;};#endif // SERVICE_FACTORY_H_EDIT Here's a driver:#include ServiceFactory.h#include <iostream>int main() {  Service* counter = ServiceFactory::getInstance()->createService(COUNTER);  if(counter) {    std::cout << Counter was made. << std::endl;    counter->free();  } else {    std::cout << Counter was not made. << std::endl;  }  return 0;}Here's the compilation process succeeding on ideone (with C++14).
Factory with raw pointers
c++;c++11