How to convert hash_map<string, string> to hash_map<wstring, wstring> using the std::transform algorithm?
<p>I know it is supposed to be easy, but I just fail to get rid of the compilation errors. Here is my code:</p>

<pre><code>template&lt;class C&gt;
struct basic_field_type_map : public hash_map&lt;basic_string&lt;C&gt;, basic_string&lt;C&gt;&gt;
{
};

typedef basic_field_type_map&lt;char&gt; field_type_map;
typedef basic_field_type_map&lt;wchar_t&gt; wfield_type_map;

wfield_type_map::value_type to_wfield_type_map_value(field_type_map::const_reference src)
{
  return wfield_type_map::value_type(to_wstring(src.first), to_wstring(src.second));
}

wfield_type_map to_wfield_type_map(const field_type_map&amp; m)
{
  wfield_type_map res;
  transform(m.begin(), m.end(), res.begin(), to_wfield_type_map_value);
  return res;
}
</code></pre>

<p>Where <code>to_wstring</code> has the following signature:</p>

<pre><code>wstring to_wstring(const string&amp; s)
</code></pre>

<p>Compiling the code gives me the following errors:</p>

<pre><code>1&gt;c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(260): error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const std::basic_string&lt;_Elem,_Traits,_Ax&gt;' (or there is no acceptable conversion)
1&gt;          with
1&gt;          [
1&gt;              _Elem=wchar_t,
1&gt;              _Traits=std::char_traits&lt;wchar_t&gt;,
1&gt;              _Ax=std::allocator&lt;wchar_t&gt;
1&gt;          ]
1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(707): could be 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;&amp;)'
1&gt;          with
1&gt;          [
1&gt;              _Elem=wchar_t,
1&gt;              _Traits=std::char_traits&lt;wchar_t&gt;,
1&gt;              _Ax=std::allocator&lt;wchar_t&gt;
1&gt;          ]
1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(761): or       'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(const std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;)'
1&gt;          with
1&gt;          [
1&gt;              _Elem=wchar_t,
1&gt;              _Traits=std::char_traits&lt;wchar_t&gt;,
1&gt;              _Ax=std::allocator&lt;wchar_t&gt;
1&gt;          ]
1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(766): or       'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(const _Elem *)'
1&gt;          with
1&gt;          [
1&gt;              _Elem=wchar_t,
1&gt;              _Traits=std::char_traits&lt;wchar_t&gt;,
1&gt;              _Ax=std::allocator&lt;wchar_t&gt;
1&gt;          ]
1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(771): or       'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(_Elem)'
1&gt;          with
1&gt;          [
1&gt;              _Elem=wchar_t,
1&gt;              _Traits=std::char_traits&lt;wchar_t&gt;,
1&gt;              _Ax=std::allocator&lt;wchar_t&gt;
1&gt;          ]
1&gt;          while trying to match the argument list '(const std::basic_string&lt;_Elem,_Traits,_Ax&gt;, const std::basic_string&lt;_Elem,_Traits,_Ax&gt;)'
1&gt;          with
1&gt;          [
1&gt;              _Elem=wchar_t,
1&gt;              _Traits=std::char_traits&lt;wchar_t&gt;,
1&gt;              _Ax=std::allocator&lt;wchar_t&gt;
1&gt;          ]
1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(259) : while compiling class template member function 'std::pair&lt;_Ty1,_Ty2&gt; &amp;std::pair&lt;_Ty1,_Ty2&gt;::operator =(std::pair&lt;_Ty1,_Ty2&gt; &amp;&amp;)'
1&gt;          with
1&gt;          [
1&gt;              _Ty1=const std::basic_string&lt;wchar_t,std::char_traits&lt;wchar_t&gt;,std::allocator&lt;wchar_t&gt;&gt;,
1&gt;              _Ty2=std::basic_string&lt;wchar_t,std::char_traits&lt;wchar_t&gt;,std::allocator&lt;wchar_t&gt;&gt;
1&gt;          ]
1&gt;          z:\dev\internal\vedtool\defs.h(34) : see reference to class template instantiation 'std::pair&lt;_Ty1,_Ty2&gt;' being compiled
1&gt;          with
1&gt;          [
1&gt;              _Ty1=const std::basic_string&lt;wchar_t,std::char_traits&lt;wchar_t&gt;,std::allocator&lt;wchar_t&gt;&gt;,
1&gt;              _Ty2=std::basic_string&lt;wchar_t,std::char_traits&lt;wchar_t&gt;,std::allocator&lt;wchar_t&gt;&gt;
1&gt;          ]
Build has been canceled.
</code></pre>

<p>I am using VS2010.</p>

<p>What am I doing wrong?</p>

<p>Thanks.</p>
