educative.io

Educative

Doubt in the move line

Hello,
Sorry, I suppose that this doubt is an absurd doubt but…why in the code line 20: set1= std::move(set2); the set2 isn’t empty after the moving operation?

Thank you.

Hi Jordi_Molist,

This is Anum from Educative. Thank you for reaching out to us. We are happy to hear from you!

The value is already set in set2 on line 7 and is not updated or deleted. So the variable set2 does not become empty after the move operation. This line of code basically sets the value of set2 in set1.

If you have any further queries, please let us know.

Happy Learning!

Best Regards,
Anum Hassan
Developer Advocate
Educative

Hi,
thank you very much for you reply.
I think that after processing the line 20 the set2 variable becomes empty because the contents of the set2 variable has moved to the set1.

After running the code, I can see that the output window is showing the sequence: 6 7 8 9 only five times and not 6 like would indicate the comments of the code.

image

I think that the comment of the line 23 is wrong.

Best regards,
Jordi.

Hi Jordi,
Thanks for pointing that out. We have updated that in our course.
Again, thank you for your valuable feedback.

If you have any further queries, please let us know.

Happy Learning!

Best Regards,
Anum Hassan
Developer Advocate
Educative