Note that there are some explanatory texts on larger screens.

plurals
  1. POVC10 unordered_set/map move constructor bug?
    primarykey
    data
    text
    <p>It seems that the move constructors of unordered_set/map under VC10 (Visual Studio 2010) puts the right hand side to an undefined state after being invoked, causing other operations (such as 'insert') to fail miserably. The move assignment operators seem to work fine. The normal set/map seem to behave correctly under all cases though. Furthermore, everything seems to be working fine under VC11 (Visual Studio 2012).</p> <p>Is this a bug on the _Hash implementation under VC10 or I am missing anything? Thanks in advance for any inputs!</p> <pre><code>#include &lt;set&gt; #include &lt;map&gt; #include &lt;unordered_set&gt; #include &lt;unordered_map&gt; std::set&lt;int&gt; si0; std::unordered_set&lt;int&gt; usi0; std::map&lt;int, int&gt; mii0; std::unordered_map&lt;int, int&gt; umii0; int _tmain(int argc, _TCHAR* argv[]) { si0.insert(0); si0.insert(1); si0.insert(2); std::set&lt;int&gt; si( std::move(si0) ); // fine! si0.insert(666); usi0.insert(0); usi0.insert(1); usi0.insert(2); //std::unordered_set&lt;int&gt; usi( std::move(usi0) ); // this seems to put usi0 to an undefined state, which makes 'insert' below cry! std::unordered_set&lt;int&gt; usi; usi = std::move(usi0); // this works! usi0.insert(666); mii0[0] = 0; mii0[1] = 1; mii0[2] = 2; std::map&lt;int, int&gt; mii( std::move(mii0) ); // fine! mii0[666] = 666; umii0[0] = 0; umii0[1] = 1; umii0[2] = 2; //std::unordered_map&lt;int, int&gt; umii( std::move(umii0) ); // this seems to put umii0 to an undefined state, which makes 'insert' below cry! std::unordered_map&lt;int, int&gt; umii; umii = std::move(umii0); // this works! umii0[666] = 666; return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload