Containers
deadalnix
deadalnix at gmail.com
Wed Sep 1 11:45:32 UTC 2021
On Wednesday, 1 September 2021 at 11:13:27 UTC, Steven
Schveighoffer wrote:
> Isn't the reason they prohibited COW is because of the problems
> with it?
>
> Not saying COW is terrible in all cases, just that a generic
> container (non-specialized usage) should not be COW. If you
> need that feature, you should have to ask for it, not have it
> be an implementation detail.
>
> -Steve
Well I never experienced any problem with them, so did many other
C++ users. As far as i am concerned, this was a net step backward.
That being said, the reason were due to iterator invalidation.
There are several function in the string API that do not
invalidate iterators, as per the C++ standard, and these function
might end up copying the content of the string in some specific
situations, which would invalidate iterators.
In practice, I think the main problem here is related to exposing
the innards of the datastructure. An iterator that contains a
reference to the container + index, rather than some kind of raw
pointer for instance, could avoid that problem.
More information about the Digitalmars-d
mailing list