Is it possible to customize the reference
of a std::vector
.
Until C++11 it seemed to be possible through the Allocator
template param
If this is so, generally speaking what is the logic for all these constrains?
The purpose is to stop promising things C++ cannot deliver.
Back in the C++98/03 days, it was thought that proxy types, specialized references and the like could really work with standard library containers and algorithms. By the time C++11 rolled around, it had become abundantly clear that... no, they really can't. Or at least, not with the same semantics as an actual language reference.
With that wisdom in mind, C++11 removed a lot of these no-longer-reasonable customization points. The typedefs were left in, but mainly for backwards-compatibility's sake.
which seems to indicate that it is still possible to specify a reference type via the allocator (_traits?).
No, it isn't. This is a bug in libstdc++; reference
is required to be value_type&
for containers now. allocator_traits
has no reference
customization point.