There is no need to pass the vector itself. Iterators provide just enough information (notice that the real work is done by
partition
algorithm, and it doesn't needv
).partition
doesn't look correct:i = left - 1
is an invalid iterator whenleft
isv.begin()
. It doesn't matter that you never dereference it, mere computation computation is an undefined behaviour.Semi-open ranges are usually more convenient than closed ones.
There is no need to pass the vector itself. Iterators provide just enough information (notice that the real work is done by
partition
algorithm, and it doesn't needv
).partition
doesn't look correct:i = left - 1
is an invalid iterator whenleft
isv.begin()
. It doesn't matter that you never dereference it, mere computation is an undefined behaviour.Semi-open ranges are usually more convenient than closed ones.
There is no need to pass the vector itself. Iterators provide just enough information (notice that the real work is done by
partition
algorithm, and it doesn't needv
).partition
doesn't look correct:i = left - 1
is an invalid iterator whenleft
isv.begin()
. It doesn't matter that you never dereference it, mere computation is an undefined behaviour.Semi-open ranges are usually more convenient than closed ones.
There is no need to pass the vector itself. Iterators provide just enough information (notice that the real work is done by
partition
algorithm, and it doesn't needv
).partition
doesn't look correct:i = left - 1
is an invalid iterator whenleft
isv.begin()
. It doesn't matter that you never dereference it, mere computation is an undefined behaviour.Semi-open ranges are usually more convenient than closed ones.