title: "<class name> does not provide a call operator" error when trying to wrap function return value
body: <p>I'm trying to write a function that will take a functor as an argument, invoke the functor and then return its return value wrapped in a <code>boost::shared_ptr</code>.</p>
  
  <p>The following refuses to compile and I'm all out of ideas. I get "std::vector&lt; std::string > does not provide a call operator" (roughly). I'm using Clang 3.1 on Mac OS X.</p>
  
  <pre><code>template&lt; typename T &gt;
  boost::shared_ptr&lt; T &gt; ReturnValueAsShared(
      boost::function&lt; T() &gt; func )
  {
    return boost::make_shared&lt; T &gt;( func() );
  }
  </code></pre>
  
  <p>This is the context in which I'm trying to use it:</p>
  
  <pre><code>make_shared&lt; packaged_task&lt; boost::shared_ptr&lt; std::vector&lt; std::string &gt; &gt; &gt; &gt;(
     bind( ReturnValueAsShared&lt; std::vector&lt; std::string &gt; &gt;,
        bind( [a function that returns a std::vector&lt; std::string &gt;] ) ) );
  </code></pre>
  
  <p>EDIT: Here's a complete self-contained test case. This code fails to compile with the same error, and for the life of me I can't see what's wrong:</p>
  
  <pre><code>#include &lt;boost/make_shared.hpp&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  #include &lt;boost/function.hpp&gt;
  #include &lt;boost/bind.hpp&gt;
  
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  std::vector&lt; std::string &gt; foo( std::string a )
  {
    std::vector&lt; std::string &gt; vec;
    vec.push_back( a );
    return vec;
  }
  
  template&lt; typename T &gt;
  boost::shared_ptr&lt; T &gt; ReturnValueAsShared(
      boost::function&lt; T() &gt; func )
  {
    return boost::make_shared&lt; T &gt;( func() );
  }
  
  int main()
  {
    auto f = boost::bind( ReturnValueAsShared&lt; std::vector&lt; std::string &gt; &gt;,
                          boost::bind( foo, std::string("a") ) );
    f();
  
  } // main
  </code></pre>
  
  <p>And here's the error output:</p>
  
  <pre><code>In file included from testcase.cpp:3:
  In file included from /usr/local/include/boost/function.hpp:64:
  In file included from /usr/local/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:47:
  In file included from /usr/local/include/boost/function/detail/function_iterate.hpp:14:
  In file included from /usr/local/include/boost/function/detail/maybe_include.hpp:13:
  /usr/local/include/boost/function/function_template.hpp:132:18: error: type 'std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt;' does not provide a call operator
            return (*f)(BOOST_FUNCTION_ARGS);
                   ^~~~
  /usr/local/include/boost/function/function_template.hpp:907:53: note: in instantiation of member function 'boost::detail::function::function_obj_invoker0&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt;, std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt;::invoke' requested here
          { { &amp;manager_type::manage }, &amp;invoker_type::invoke };
                                                      ^
  /usr/local/include/boost/function/function_template.hpp:722:13: note: in instantiation of function template specialization 'boost::function0&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt;::assign_to&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt;' requested here
        this-&gt;assign_to(f);
              ^
  /usr/local/include/boost/function/function_template.hpp:1042:5: note: in instantiation of function template specialization 'boost::function0&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt;::function0&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt;' requested here
      base_type(f)
      ^
  /usr/local/include/boost/bind/bind.hpp:243:43: note: in instantiation of function template specialization 'boost::function&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; ()&gt;::function&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt;' requested here
          return unwrapper&lt;F&gt;::unwrap(f, 0)(a[base_type::a1_]);
                                            ^
  /usr/local/include/boost/bind/bind_template.hpp:20:27: note: in instantiation of function template specialization 'boost::_bi::list1&lt;boost::_bi::bind_t&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt;, std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; (*)(std::basic_string&lt;char&gt;), boost::_bi::list1&lt;boost::_bi::value&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt; &gt;::operator()&lt;boost::shared_ptr&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt;, boost::shared_ptr&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt; (*)(boost::function&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; ()&gt;), boost::_bi::list0&gt;' requested here
          BOOST_BIND_RETURN l_(type&lt;result_type&gt;(), f_, a, 0);
                            ^
  testcase.cpp:27:4: note: in instantiation of member function 'boost::_bi::bind_t&lt;boost::shared_ptr&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt;, boost::shared_ptr&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt; (*)(boost::function&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; ()&gt;), boost::_bi::list1&lt;boost::_bi::bind_t&lt;std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt;, std::vector&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt; (*)(std::basic_string&lt;char&gt;), boost::_bi::list1&lt;boost::_bi::value&lt;std::basic_string&lt;char&gt; &gt; &gt; &gt; &gt; &gt;::operator()' requested here
    f();
     ^
  1 error generated.
  </code></pre>
  
  <p>Here are some more clues. The following code compiles just fine, but that doesn't help me since this is not the code that I want :)</p>
  
  <pre><code>#include &lt;boost/make_shared.hpp&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  #include &lt;boost/function.hpp&gt;
  #include &lt;boost/bind.hpp&gt;
  
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  std::vector&lt; std::string &gt; foo()
  {
    std::vector&lt; std::string &gt; vec;
    return vec;
  }
  
  template&lt; typename T &gt;
  boost::shared_ptr&lt; T &gt; ReturnValueAsShared(
      boost::function&lt; T() &gt; func )
  {
    return boost::make_shared&lt; T &gt;( func() );
  }
  
  int main()
  {
    auto f = boost::bind( ReturnValueAsShared&lt; std::vector&lt; std::string &gt; &gt;,
                          foo );
    f();
  
  } // main
  </code></pre>