Standard containers define CopyConstructible and Assignable requirements for the value type, and these requirements are sufficient to support all operations with containers and sequences (you may also want them to be comparable for associative containers, but even this is not required since you can supply a comparator instead) .
What you are asking for is to have one set of requirements for a set of operations consisting of a part of a container plus something from a sequence (namely the 1-parameter resize() in those containers that never move their contents, operator[] , clear() and the iterator interface, excluding *it = t ), and another set of requirements for the rest. Standard libraries prefer to do this the other way around: select a general set of requirements that cover almost everything, and then have additional requirements for small functionality (for example, the requirement to be the default line by line for calling resize() without specifying the second parameter).
The containers were simply not designed for your specific set of operations - copying and assignment are an integral part of what they are designed to do, which should contain the values that they put into them, so I assume that in Stepanov’s mind this is not “little functionality” " Thus, broader requirements exist because the Container abstraction is larger than the proposed ResizeableCollectionOfDefaultConstructedObjects. In fact, take resize() , and CollectionOfDefaultConstructedObjects is just an array. I assume that the designers of the STL and C ++ standard did not meet your use case often enough to think that it should be disregarded.
source share