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

Consider a move assign to a vector<int> from src to this. The first step is for this to free its resources, the second step is to assign src resources to this, the third step is to set src resources to null.

If src and this are equal and you don't check for it, then you end up destroying src/this resources and the end result would be an empty vector (since the last step is to clear everything out).

The expected behavior is a no-op.



Right you said move but I was thinking of swap for some reason.

I probably still wouldn't care, unless it's clear that moving to self is even required. Trying to break everything in a thousand pieces and generalizing and perfecting them individually is a lot of busywork.




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

Search: