Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Read what I wrote again. I said all member functions.

Reusing of a moved from object only requires assignment and destruction to be well behaved.

The std library containers give you extra guarantees (a moved from object is effectively the same as a default constructed one), but the _language_ imposes no such requirements on your types

It's perfectly allowed by the language for the .size() member of your own vector type to return a random value after it's been moved from because you wanted to save 1 CPU instruction somewhere.



I understand what you're saying but no major compiler does anything nefarious. They default initialize it. A lot of code depends on std::optional that was moved from returning false for is_valid for instance and no one would break that even if it's not guaranteed.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: