title: Passing arguments in constructor with boost factory
body: <p>I am fairly new with the whole factory implementation and as a result maybe my question will sound wrong and not very well defined. 
  So, with few words I want to have a boost factoty in order to initialize a banch fo derived classes and so far I have managed to do so for classes with empty constructors. Let me present to my current boost factory implementation for two small classes:</p>
  
  <p><strong>Base.h:</strong> </p>
  
  <pre><code>#ifndef BASE_H_
  #define BASE_H_
  
  #include &lt;vector&gt;
  #include &lt;map&gt;
  #include "boost/function.hpp"
  
  class base {
  
  protected:
      typedef boost::function &lt;base *()&gt; basefactory;
  
  public:
        base();
        virtual ~base();
  
       int a;
  
       static std::map&lt;std::string,base::basefactory&gt;&amp; b_factory();
  
    };
  
  #endif /* BASE_H_ */
  </code></pre>
  
  <p><strong>Base.cpp:</strong>  </p>
  
  <pre><code>#include "base.h"
  
  base::base() {
     // TODO Auto-generated constructor stub
  }
  
  base::~base() {
    // TODO Auto-generated destructor stub
  }
  
  static std::map&lt;std::string,base::basefactory&gt;&amp; base::b_factory()
  {
    static std::map&lt;std::string,base::basefactory&gt;* ans =
    new std::map&lt;std::string,base::basefactory&gt;();
    return *ans;
  }
  </code></pre>
  
  <p><strong>Derived.h :</strong></p>
  
  <pre><code>#ifndef DERIVED_H_
  #define DERIVED_H_
  
  #include "boost/function.hpp"
  #include "boost/functional/factory.hpp"
  #include &lt;iostream&gt;
  
  #include "base.h"
  
  class derived : public base {
       public:
           derived();
           virtual ~derived();
  
            int b;
  
            static class _init {
              public:
                 _init() {
                         base::b_factory()["derived"] = boost::factory&lt;derived*&gt;();
                         }
             }_initializer;
  
   };
  
   #endif /* DERIVED_H_ */
  </code></pre>
  
  <p><strong>Derived.cpp:</strong></p>
  
  <pre><code>#include "derived.h"
  
  derived::derived() {
      // TODO Auto-generated constructor stub
  }
  
  derived::~derived() {
      // TODO Auto-generated destructor stub
  }
  
  derived::_init derived::_initializer;
  </code></pre>
  
  <p>So, the above desplayed code works just fine for empty constructor of the classes, but I am very unsure how to modify the code in case the base and derived class constructors need to receive arguments. More specifically let's say that I want to have the base constructor:</p>
  
  <pre><code>base(int alpha) { 
  a = alpha;
  }
  </code></pre>
  
  <p>And also the derived constructor:</p>
  
  <pre><code>derived(int alpha, int beta) : base( alpha ) // in order to pass the argument alpha to the base class
  { 
      b = beta;
  }
  </code></pre>
  
  <p>So, as said above I am really unsure what modifications I need to do in order to manage to have the above boost factory implementation working for my code.
  I know there are some posts in here in elsewhere online for parametrized constructors but they didn't manage to make me properly understand how to do it myself and that's why I made this post her.
  Any kind of help/suggestion would be much appreciated!</p>