[ ... ]
I've been wondering about this. What about the allocators?
I believe that's correct. In fact, table 32 specifies equality for
Allocators in exactly those terms: "a1 == a2 ... returns true iff
storage allocated from each can be deallocated via the other."
Which supposes that if it returns false, they probably can't be.
Implementations of containers described in this International
Standard are permitted to assume that their Allocator
template parameter meets the following two additional
requirements beyond those in Table 32.
? All instances of a given allocator type are required to be
interchangeable and always compare equal to each other.
Implementors are encouraged to supply libraries that can accept
allocators that encapsulate more general memory models and that
support non-equal instances. In such implementations, any
requirements imposed on allocators by containers beyond those
requirements that appear in Table 32, and the semantics of con-
tainers and algorithms when allocator instances compare non-
equal, are implementation-defined.
Which is pretty weasely, if you ask me. Does == on an allocator
mean anything, or not? The answer is an unqualified and
decisive maybe.
As such, I'd say non-equal allocators leads to undefined
behavior as a rule, though it might only be implementation
defined behavior instead -- but if so, there may also be
implementation defined requirements to get the implementation
defined behavior (e.g. swap of containers won't throw -- but
swapping allocators can't throw either).
In sum, if an implementation decides to support non-equal
allocators, it is free to choose: require them to support swap
(possibly by having a no-throw copy constructor and assignment
operator, so that std::swap will work), accept that swap might
throw if the allocators are not equal (along the lines of
Compare), or accept that swap is not constant time if the
allocators are not equal.
It's a shame we don't hear much from Plauger any more. I know
that his implementation does support non-equal allocators; I'd
be interesting in hearing which option he chose, and why. (I'd
If I understand your question correctly, I think the section
above covers it.
In other words, the standard has intentionally decided to duck
the issue.