C++ Logo


Advanced search

Re: On "transparently replaceable" in std::vector operations

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Fri, 30 Apr 2021 16:49:32 +0200
pt., 30 kwi 2021 o 16:17 Hyman Rosen via Std-Discussion
<std-discussion_at_[hidden]> napisaƂ(a):
> This is where the conceptual error of the C++ object model shows. A pointer or reference points to memory, not to an object. The pointer type informs how that memory should be treated. If the memory remains allocated to the program, the pointer is valid. If the contents of the memory are valid for a type, the object of that type in that memory is valid.
> Your deciding for all programmers that when they have pointers to vector elements they "really" mean some theoretical element that wanders around within the vector is no more valid than if you decided the same for pointers to array elements. You are breaking people's code or making it harder for them to work so that you can satisfy yourself about some useless abstract principle being followed.

Isn't this whole point of standard? saying what is allowed and what
not? Especially for C++ that tries to separate itself from concrete
implementation and its details.
Goal of C++ is to have same program behavior on a maximum number of
machines and this needs sacrificing some details to make it work
without big overhead.

If tools that give C++ do not match your expectations then switch to
another language that fit your expectations or adjust your
expectations for C++.

Please do not try to push a square peg to a round hole.

Received on 2021-04-30 09:49:45