title: c++11 Template Factory pattern and constructor with parameters
body: <p>I'm trying to make a c++11 templated factory with automatic registration,
  I pretty much followed this: <a href="http://www.drdobbs.com/conversations-abstract-factory-template/184403786" rel="nofollow">http://www.drdobbs.com/conversations-abstract-factory-template/184403786</a></p>
  
  <p>So I have a AFactory  like this: </p>
  
  <pre><code>template&lt;class BaseType, typename IDKey = std::string&gt;
  class AFactory : public Singleton&lt;AFactory&lt;BaseType, IDKey&gt;&gt;
  {
  friend class Singleton&lt;AFactory&gt;;
  
  private:
      typedef std::unique_ptr&lt;BaseType&gt;(*typeCreator)();
  
  public:
      AFactory() = default;
      ~AFactory() = default;
  
      AFactory(const AFactory&amp;) = delete;
      AFactory&amp; operator=(const AFactory&amp;) = delete;
  
      void registerNewClass(const IDKey&amp; key, const typeCreator&amp; creator)
      {
          _registerTypes.insert({key, creator});
      };
  
      template&lt;typename... Args&gt;
      std::unique_ptr&lt;BaseType&gt; create(const IDKey&amp; key, Args&amp;&amp;... args) const
      {
          return (_registerTypes.at(key))(std::forward&lt;Args&gt;(args)...);
      };
  
  private:
      std::unordered_map&lt;IDKey, typeCreator&gt; _registerTypes;
  };
  </code></pre>
  
  <p>And a registration class like that:</p>
  
  <pre><code>template&lt;class BaseType, class RealType, typename IDKey = std::string&gt;
  class AFactoryRegistration
  {
  public:
      AFactoryRegistration(const IDKey&amp; key)
      {
          AFactory&lt;BaseType&gt;::instance().registerNewClass(key, &amp;instancier);
      };
  
      ~AFactoryRegistration() = default;
      AFactoryRegistration(const AFactoryRegistration&amp;) = delete;
      AFactoryRegistration&amp; operator=(const AFactoryRegistration&amp;) = delete;
  
      static std::unique_ptr&lt;BaseType&gt; instancier()
      {
          return std::unique_ptr&lt;BaseType&gt;(new RealType());
      };
  };
  </code></pre>
  
  <p>But I still have a problem with classes which take construction parameters.
  For example if I have a class:</p>
  
  <pre><code>class Point : public stuff
  {
  public:
  Point(int x, int y);
  /*...*/
  
  };
  </code></pre>
  
  <p>How can I register the class Point to the factory taking the constructor Point(int x, int y) ?</p>