title: Filling std::map with std::transform (error: cannot deduce argument)
body: <p>I'm trying to fill std::map with std::transform. Next code compiles without error:</p>
  
  <pre><code>std::set&lt;std::wstring&gt; in; // "in" is filled with data
  std::map&lt;std::wstring, unsigned&gt; out;
  
  std::transform(in.begin(), in.end()
  ,   boost::counting_iterator&lt;unsigned&gt;(0)
  ,   std::inserter(out, out.end())
  ,   [] (std::wstring _str, unsigned _val) { return std::make_pair(_str, _val); }
  );
  </code></pre>
  
  <p>But If I replace string</p>
  
  <pre><code>,   [] (std::wstring _str, unsigned _val) { return std::make_pair(_str, _val); }
  </code></pre>
  
  <p>with</p>
  
  <pre><code>,   std::make_pair&lt;std::wstring, unsigned&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>,   std::ptr_fun(std::make_pair&lt;std::wstring, unsigned&gt;)
  </code></pre>
  
  <p>I get errors:</p>
  
  <pre><code>foo.cpp(327): error C2784: '_OutTy *std::transform(_InIt1,_InIt1,_InTy (&amp;)[_InSize],_OutTy (&amp;)[_OutSize],_Fn2)' : could not deduce template argument for '_InTy (&amp;)[_InSize]' from 'boost::counting_iterator&lt;Incrementable&gt;'
        with
        [
            Incrementable=unsigned int
        ]
        C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\algorithm(1293) : see declaration of 'std::transform'
  foo.cpp(327): error C2784: '_OutTy *std::transform(_InIt1,_InIt1,_InIt2,_OutTy (&amp;)[_OutSize],_Fn2)' : could not deduce template argument for '_OutTy (&amp;)[_OutSize]' from 'std::insert_iterator&lt;_Container&gt;'
        with
        [
            _Container=std::map&lt;std::wstring,unsigned int&gt;
        ]
        C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\algorithm(1279) : see declaration of 'std::transform'
  foo.cpp(327): error C2784: '_OutIt std::transform(_InIt1,_InIt1,_InTy (&amp;)[_InSize],_OutIt,_Fn2)' : could not deduce template argument for '_InTy (&amp;)[_InSize]' from 'boost::counting_iterator&lt;Incrementable&gt;'
        with
        [
            Incrementable=unsigned int
        ]
        C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\algorithm(1267) : see declaration of 'std::transform'
  foo.cpp(327): error C2914: 'std::transform' : cannot deduce template argument as function argument is ambiguous
  </code></pre>
  
  <p>and so on...
  Please explain what is the problem is with compilation?</p>
  
  <p><strong>UPDATE:</strong> Thanks for answers. I realized, that it is MSVC2010 bug. By the way the line</p>
  
  <pre><code>&amp;std::make_pair&lt;const std::wstring&amp;, const unsigned&amp;&gt;
  </code></pre>
  
  <p>causes the same error</p>