Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8652995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:26:11+00:00 2026-06-12T14:26:11+00:00

It seems that the move constructors of unordered_set/map under VC10 (Visual Studio 2010) puts

  • 0

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).

Is this a bug on the _Hash implementation under VC10 or I am missing anything? Thanks in advance for any inputs!

#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

std::set<int> si0;
std::unordered_set<int> usi0;

std::map<int, int> mii0;
std::unordered_map<int, int> umii0;

int _tmain(int argc, _TCHAR* argv[])
{
    si0.insert(0);
    si0.insert(1);
    si0.insert(2);
    std::set<int> si( std::move(si0) ); // fine!
    si0.insert(666);

    usi0.insert(0);
    usi0.insert(1);
    usi0.insert(2);
    //std::unordered_set<int> usi( std::move(usi0) ); // this seems to put usi0 to an undefined state, which makes 'insert' below cry!
    std::unordered_set<int> usi; usi = std::move(usi0); // this works!
    usi0.insert(666);

    mii0[0] = 0;
    mii0[1] = 1;
    mii0[2] = 2;
    std::map<int, int> mii( std::move(mii0) ); // fine!
    mii0[666] = 666;

    umii0[0] = 0;
    umii0[1] = 1;
    umii0[2] = 2;
    //std::unordered_map<int, int> umii( std::move(umii0) ); // this seems to put umii0 to an undefined state, which makes 'insert' below cry!
    std::unordered_map<int, int> umii; umii = std::move(umii0); // this works!
    umii0[666] = 666;

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:26:12+00:00Added an answer on June 12, 2026 at 2:26 pm

    Alrighty, after digging more into the _Hash class implementation under VC10, and comparing it to that of VC11, I noticed that the move constructor of _Hash class under VC10 never initializes its ‘_Max_bucket_size’ member, and the logic then swaps this uninitialized value to the right hand side (the moved _Hash instance), leaving the right hand side in an uninitialized state.

    This is fine if the right hand side of the move constructor is really a temporary object, but my logic relies on the move constructor to “reset” the right hand side object, and the right hand side object will be reconstructed thereafter.

    The move assignment version works in that it requires the left hand side object to be somehow properly constructed (in this case, default constructed, with ‘_Max_bucket_size’ properly initialized), and when swapping it to the right side, the right hand side is not left in a bad state. Nevertheless, leaving the right hand side taking the swapped state from the left hand side does not conform to the standard behavior of move assignment operator, which should reset the right hand side, which does something more than pure swapping!

    The corresponding implementation in VC11 seems to have corrected the behavior and conform to the standard.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems that both of them could make the element move from its current
It seems that if I want to move to a next function in Nodejs
I have an app with CALayers that move from one side of the screen
Seems that This will be an easy question for you but this problem is
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch
It seems that we can show layers and even use a different zPosition for
It seems that runClasses() doesn't terminate the code being tested even after the test
It seems that JavaScript's Date() function can only return local date and time. Is
It seems that often I find that my code when moving either from one
It seems that it is not advisable to use <meta http-equiv=REFRESH CONTENT=3;url=url> for redirects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.