title: Cross-platform way to create a boost::function from function pointer
body: <p>I've been writing some templates that expect to be passed a boost::function.  They determine the arguments to the boost::function and then use that to create an appropriate specialization of a class.  For example, this is the template for 0 arguments:</p>
  
  <pre><code>template&lt; class ReturnT &gt;
  MyFunctionPtr MakeFunction( boost::function&lt; ReturnT (  ) &gt; func )
  {
      return MyFunctionPtr( new MyFunction&lt; decltype( func ), ReturnT &gt;( func ) );
  }
  </code></pre>
  
  <p>As a bit of a shortcut I've got another version of the MakeFunction template that takes in a function pointer and automatically wraps it in a boost::function of the appropriate type: </p>
  
  <pre><code>template&lt; class T &gt;
  MyFunctionPtr MakeFunctionFromPointer( T func )
  {
      return MakeFunction( 
          boost::function&lt; typename boost::remove_pointer&lt;T&gt;::type &gt;( func )
          );
  }
  </code></pre>
  
  <p>This allows me to create from function pointers without explicitly passing in the function spec:</p>
  
  <pre><code>int something() { return 1; }
  MakeFunctionFromPointer( &amp;something );
  </code></pre>
  
  <p>On MSVC this is working fine but with GCC 4.3 I get "no matching function" errors.  It appears that:</p>
  
  <p>On MSVC <code>boost::remove_pointer&lt; bool (*)() &gt;::type</code> is <code>bool ()</code></p>
  
  <p>But on GCC 4.3: <code>boost::remove_pointer&lt; bool (*)() &gt;::type</code> is <code>bool ()()</code></p>
  
  <p>So on GCC an appropriate template of MakeFunction does not exist.</p>
  
  <p>Is there any way I can alter the output on remove_pointer output on either platform to match the other?  Or is there an other way I can go about solving this problem?</p>