Overloading T and vector<T>
<p>I have a static method <code>ToString(T)</code> and an overload <code>ToString(vector&lt;T&gt;)</code>. This works for normal use, but not with boost bind. See my example code:</p>

<pre><code>#include &lt;boost/bind.hpp&gt;
#include &lt;boost/function.hpp&gt;
#include &lt;boost/lexical_cast.hpp&gt;
#include &lt;iostream&gt;
#include &lt;sstream&gt;
#include &lt;vector&gt;

class MetaData
{
public:
    template&lt;typename T&gt;
    static std::string ToString(T inValue)
    {
        return boost::lexical_cast&lt;std::string&gt;(inValue);
    }

    template&lt;typename T&gt;
    static std::string ToString(const std::vector&lt;T&gt; &amp; inValues)
    {
        std::stringstream ss;
        for (typename std::vector&lt;T&gt;::size_type idx = 0; idx &lt; inValues.size(); ++idx)
        {
            if (idx != 0)
            {
                ss &lt;&lt; ", ";
            }
            ss &lt;&lt; inValues[idx];
        }
        return ss.str();
    }

    int getInt() { return 42; }

    std::vector&lt;int&gt; getIntVector()
    {
        std::vector&lt;int&gt; result;
        result.push_back(1);
        result.push_back(2);
        result.push_back(3);
        return result;
    }

    void test();
};

void MetaData::test()
{
    boost::function&lt; std::string() &gt; foo;

    // Ok
    foo = boost::bind(&amp;ToString&lt;int&gt;, boost::bind(&amp;MetaData::getInt, this));
    std::cout &lt;&lt; foo() &lt;&lt; std::endl;

    // Compiler errors
    foo = boost::bind(&amp;ToString&lt;int&gt;, boost::bind(&amp;MetaData::getIntVector, this));
    std::cout &lt;&lt; foo() &lt;&lt; std::endl;

    // Ok
    std::cout &lt;&lt; ToString&lt;int&gt;(getIntVector()) &lt;&lt; std::endl;
}

int main()
{
    MetaData metaData;
    metaData.test();
}
</code></pre>

<p>Does anyone know what I'm doing wrong?</p>

<p><b>Edit</b><br/>
These are the compiler errors I'm getting:</p>

<pre><code>/usr/include/boost/bind/bind.hpp: In member function ‘R boost::_bi::list1&lt;A1&gt;::operator()(boost::_bi::type&lt;R&gt;, F&amp;, A&amp;, long int) [with R = std::basic_string&lt;char&gt;, F = std::basic_string&lt;char&gt; (*)(int), A = boost::_bi::list0, A1 = boost::_bi::bind_t&lt;std::vector&lt;int&gt;, boost::_mfi::mf0&lt;std::vector&lt;int&gt;, MetaData&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;MetaData*&gt; &gt; &gt;]’:
/usr/include/boost/bind/bind_template.hpp:20:59:   instantiated from ‘boost::_bi::bind_t&lt;R, F, L&gt;::result_type boost::_bi::bind_t&lt;R, F, L&gt;::operator()() [with R = std::basic_string&lt;char&gt;, F = std::basic_string&lt;char&gt; (*)(int), L = boost::_bi::list1&lt;boost::_bi::bind_t&lt;std::vector&lt;int&gt;, boost::_mfi::mf0&lt;std::vector&lt;int&gt;, MetaData&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;MetaData*&gt; &gt; &gt; &gt;, boost::_bi::bind_t&lt;R, F, L&gt;::result_type = std::basic_string&lt;char&gt;]’
/usr/include/boost/function/function_template.hpp:132:42:   instantiated from ‘static R boost::detail::function::function_obj_invoker0&lt;FunctionObj, R&gt;::invoke(boost::detail::function::function_buffer&amp;) [with FunctionObj = boost::_bi::bind_t&lt;std::basic_string&lt;char&gt;, std::basic_string&lt;char&gt; (*)(int), boost::_bi::list1&lt;boost::_bi::bind_t&lt;std::vector&lt;int&gt;, boost::_mfi::mf0&lt;std::vector&lt;int&gt;, MetaData&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;MetaData*&gt; &gt; &gt; &gt; &gt;, R = std::basic_string&lt;char&gt;]’
/usr/include/boost/function/function_template.hpp:913:60:   instantiated from ‘void boost::function0&lt;R&gt;::assign_to(Functor) [with Functor = boost::_bi::bind_t&lt;std::basic_string&lt;char&gt;, std::basic_string&lt;char&gt; (*)(int), boost::_bi::list1&lt;boost::_bi::bind_t&lt;std::vector&lt;int&gt;, boost::_mfi::mf0&lt;std::vector&lt;int&gt;, MetaData&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;MetaData*&gt; &gt; &gt; &gt; &gt;, R = std::basic_string&lt;char&gt;]’
/usr/include/boost/function/function_template.hpp:722:7:   instantiated from ‘boost::function0&lt;R&gt;::function0(Functor, typename boost::enable_if_c&lt;boost::type_traits::ice_not&lt;boost::is_integral&lt;Functor&gt;::value&gt;::value, int&gt;::type) [with Functor = boost::_bi::bind_t&lt;std::basic_string&lt;char&gt;, std::basic_string&lt;char&gt; (*)(int), boost::_bi::list1&lt;boost::_bi::bind_t&lt;std::vector&lt;int&gt;, boost::_mfi::mf0&lt;std::vector&lt;int&gt;, MetaData&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;MetaData*&gt; &gt; &gt; &gt; &gt;, R = std::basic_string&lt;char&gt;, typename boost::enable_if_c&lt;boost::type_traits::ice_not&lt;boost::is_integral&lt;Functor&gt;::value&gt;::value, int&gt;::type = int]’
/usr/include/boost/function/function_template.hpp:1064:16:   instantiated from ‘boost::function&lt;R()&gt;::function(Functor, typename boost::enable_if_c&lt;boost::type_traits::ice_not&lt;boost::is_integral&lt;Functor&gt;::value&gt;::value, int&gt;::type) [with Functor = boost::_bi::bind_t&lt;std::basic_string&lt;char&gt;, std::basic_string&lt;char&gt; (*)(int), boost::_bi::list1&lt;boost::_bi::bind_t&lt;std::vector&lt;int&gt;, boost::_mfi::mf0&lt;std::vector&lt;int&gt;, MetaData&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;MetaData*&gt; &gt; &gt; &gt; &gt;, R = std::basic_string&lt;char&gt;, typename boost::enable_if_c&lt;boost::type_traits::ice_not&lt;boost::is_integral&lt;Functor&gt;::value&gt;::value, int&gt;::type = int]’
/usr/include/boost/function/function_template.hpp:1105:5:   instantiated from ‘typename boost::enable_if_c&lt;boost::type_traits::ice_not&lt;boost::is_integral&lt;Functor&gt;::value&gt;::value, boost::function&lt;R()&gt;&amp;&gt;::type boost::function&lt;R()&gt;::operator=(Functor) [with Functor = boost::_bi::bind_t&lt;std::basic_string&lt;char&gt;, std::basic_string&lt;char&gt; (*)(int), boost::_bi::list1&lt;boost::_bi::bind_t&lt;std::vector&lt;int&gt;, boost::_mfi::mf0&lt;std::vector&lt;int&gt;, MetaData&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;MetaData*&gt; &gt; &gt; &gt; &gt;, R = std::basic_string&lt;char&gt;, typename boost::enable_if_c&lt;boost::type_traits::ice_not&lt;boost::is_integral&lt;Functor&gt;::value&gt;::value, boost::function&lt;R()&gt;&amp;&gt;::type = boost::function&lt;std::basic_string&lt;char&gt;()&gt;&amp;]’
main.cpp:55:81:   instantiated from here
/usr/include/boost/bind/bind.hpp:243:60: error: cannot convert ‘boost::_bi::result_traits&lt;std::vector&lt;int&gt;, boost::_mfi::mf0&lt;std::vector&lt;int&gt;, MetaData&gt; &gt;::type’ to ‘int’ in argument passing
make: *** [all] Error 1
</code></pre>
