title: Cannot create unordered_map of tuple<int, int, int>
body: <p>I'm using <code>std::unordered_map&lt;std::tuple&lt;int, int, int&gt;, float&gt;</code>. However, VS2010 will not compile the instantiation. I explicitly provided a <code>hash</code> specialization and an <code>operator==</code> overload. The error message refers to</p>
  
  <pre><code>std::unordered_map&lt;NodeType, float&gt; g_score;
  </code></pre>
  
  <p>And here is the full text of the error:</p>
  
  <pre><code>1&gt;c:\program files (x86)\microsoft visual studio 10.0\vc\include\tuple(127): error C2440: 'initializing' : cannot convert from 'const NodeType' to 'int'
  1&gt;          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xxtuple0(9) : see reference to function template instantiation 'std::tr1::_Cons_node&lt;_Car,_Cdr&gt;::_Cons_node&lt;_Ty,std::tr1::_Nil&amp;,std::tr1::_Nil&amp;,std::tr1::_Nil&amp;,std::tr1::_Nil&amp;,std::tr1::_Nil&amp;,std::tr1::_Nil&amp;,std::tr1::_Nil&amp;,std::tr1::_Nil&amp;,std::tr1::_Nil&amp;&gt;(_Farg0 &amp;&amp;,_Farg1,_Farg2,_Farg3,_Farg4,_Farg5,_Farg6,_Farg7,_Farg8,_Farg9)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Car=int,
  1&gt;              _Cdr=std::tr1::_Cons_node&lt;int,std::tr1::_Cons_node&lt;int,std::tr1::_Tuple_type&lt;std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil&gt;::_Type&gt;&gt;,
  1&gt;              _Ty=NodeType,
  1&gt;              _Farg0=NodeType,
  1&gt;              _Farg1=std::tr1::_Nil &amp;,
  1&gt;              _Farg2=std::tr1::_Nil &amp;,
  1&gt;              _Farg3=std::tr1::_Nil &amp;,
  1&gt;              _Farg4=std::tr1::_Nil &amp;,
  1&gt;              _Farg5=std::tr1::_Nil &amp;,
  1&gt;              _Farg6=std::tr1::_Nil &amp;,
  1&gt;              _Farg7=std::tr1::_Nil &amp;,
  1&gt;              _Farg8=std::tr1::_Nil &amp;,
  1&gt;              _Farg9=std::tr1::_Nil &amp;
  1&gt;          ]
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(145) : see reference to function template instantiation 'std::tr1::tuple&lt;_Arg0,_Arg1,_Arg2&gt;::tuple&lt;const std::tr1::tuple&lt;_Arg0,_Arg1,_Arg2&gt;&gt;(_Farg0 &amp;&amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Arg0=int,
  1&gt;              _Arg1=int,
  1&gt;              _Arg2=int,
  1&gt;              _Farg0=const std::tr1::tuple&lt;int,int,int&gt;
  1&gt;          ]
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(142) : while compiling class template member function 'std::_Pair_base&lt;_Ty1,_Ty2&gt;::_Pair_base(const std::tr1::tuple&lt;_Arg0,_Arg1,_Arg2&gt; &amp;&amp;,float &amp;&amp;)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Ty1=const NodeType,
  1&gt;              _Ty2=float,
  1&gt;              _Arg0=int,
  1&gt;              _Arg1=int,
  1&gt;              _Arg2=int
  1&gt;          ]
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(174) : see reference to class template instantiation 'std::_Pair_base&lt;_Ty1,_Ty2&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Ty1=const NodeType,
  1&gt;              _Ty2=float
  1&gt;          ]
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\unordered_map(279) : see reference to class template instantiation 'std::pair&lt;_Ty1,_Ty2&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Ty1=const NodeType,
  1&gt;              _Ty2=float
  1&gt;          ]
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\unordered_map(275) : while compiling class template member function 'float &amp;std::tr1::unordered_map&lt;_Kty,_Ty&gt;::operator [](const std::tr1::tuple&lt;_Arg0,_Arg1,_Arg2&gt; &amp;)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Kty=NodeType,
  1&gt;              _Ty=float,
  1&gt;              _Arg0=int,
  1&gt;              _Arg1=int,
  1&gt;              _Arg2=int
  1&gt;          ]
  1&gt;          c:\repo\render\render\sim\simcontext.cpp(155) : see reference to class template instantiation 'std::tr1::unordered_map&lt;_Kty,_Ty&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Kty=NodeType,
  1&gt;              _Ty=float
  1&gt;          ]
  1&gt;c:\program files (x86)\microsoft visual studio 10.0\vc\include\tuple(127): error C2439: 'std::tr1::_Cons_node&lt;_Car,_Cdr&gt;::_Value' : member could not be initialized
  1&gt;          with
  1&gt;          [
  1&gt;              _Car=int,
  1&gt;              _Cdr=std::tr1::_Cons_node&lt;int,std::tr1::_Cons_node&lt;int,std::tr1::_Tuple_type&lt;std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil&gt;::_Type&gt;&gt;
  1&gt;          ]
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\tuple(170) : see declaration of 'std::tr1::_Cons_node&lt;_Car,_Cdr&gt;::_Value'
  1&gt;          with
  1&gt;          [
  1&gt;              _Car=int,
  1&gt;              _Cdr=std::tr1::_Cons_node&lt;int,std::tr1::_Cons_node&lt;int,std::tr1::_Tuple_type&lt;std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil&gt;::_Type&gt;&gt;
  1&gt;          ]
  </code></pre>
  
  <p>Uncertain where to proceed, as I've never seen this error before. Any suggestions?</p>
  
  <p>Edit: Interestingly, the <code>unordered_set&lt;NodeType&gt;</code> right before this compiles cleanly.</p>
  
  <p>Try this for an SSCCE:</p>
  
  <pre><code>#include &lt;deque&gt;
  #include &lt;tuple&gt;
  #include &lt;unordered_map&gt;
  #include &lt;unordered_set&gt;
  
  void GetPath() {
      typedef std::tuple&lt;int, int, int&gt; NodeType;
      struct node_hasher : public std::unary_function&lt;const NodeType&amp;, std::size_t&gt; {
          std::size_t operator()(const NodeType&amp; node) const {
              return std::hash&lt;int&gt;()(std::get&lt;0&gt;(node) + std::get&lt;0&gt;(node) + std::get&lt;0&gt;(node) + std::get&lt;1&gt;(node) + std::get&lt;1&gt;(node) + std::get&lt;2&gt;(node));
          }
      };
      std::unordered_set&lt;NodeType, node_hasher&gt; closed_set;
      std::unordered_map&lt;NodeType, float, node_hasher&gt; g_score;
      std::unordered_map&lt;NodeType, float, node_hasher&gt; f_score;
      std::unordered_map&lt;NodeType, NodeType, node_hasher&gt; came_from;
      auto node_comparator = [&amp;](NodeType lhs, NodeType rhs) {
          return f_score[lhs] &lt; f_score[rhs];
      };
  }
  
  int main() {
  }
  </code></pre>
  
  <p>Fails to compile with the same error in the empty project. If you uncomment the <code>node_comparator</code> lambda, it works just fine. No wonder I had trouble with it- it's another VS bug.</p>