[diff.cpp03.containers] (original) (raw)

Annex C (informative) Compatibility [diff]

C.6 C++ and ISO C++ 2003 [diff.cpp03]

C.6.12 [containers]: containers library [diff.cpp03.containers]

Affected subclause: [container.requirements]

Change: Complexity of size() member functions now constant.

Rationale: Lack of specification of complexity of size() resulted in divergent implementations with inconsistent performance characteristics.

Effect on original feature: Some container implementations that conform to C++ 2003 may not conform to the specified size() requirements in this revision of C++.

Adjusting containers such as std​::​list to the stricter requirements may require incompatible changes.

Affected subclause: [container.requirements]

Change: Requirements change: relaxation.

Rationale: Clarification.

Effect on original feature: Valid C++ 2003 code that attempts to meet the specified container requirements may now be over-specified.

Code that attempted to be portable across containers may need to be adjusted as follows:

Affected subclause: [container.requirements]

Change: Requirements change: default constructible.

Rationale: Clarification of container requirements.

Effect on original feature: Valid C++ 2003 code that attempts to explicitly instantiate a container using a user-defined type with no default constructor may fail to compile.

Affected subclauses: [sequence.reqmts] and [associative.reqmts]

Change: Signature changes: from void return types.

Rationale: Old signature threw away useful information that may be expensive to recalculate.

Effect on original feature: The following member functions have changed:

Valid C++ 2003 code that relies on these functions returning void(e.g., code that creates a pointer to member function that points to one of these functions) will fail to compile with this revision of C++.

Affected subclauses: [sequence.reqmts] and [associative.reqmts]

Change: Signature changes: from iterator to const_iteratorparameters.

Rationale: Overspecification.

Effect on original feature: The signatures of the following member functions changed from taking aniterator to taking a const_iterator:

Valid C++ 2003 code that uses these functions may fail to compile with this revision of C++.

Affected subclauses: [sequence.reqmts] and [associative.reqmts]

Change: Signature changes: resize.

Rationale: Performance, compatibility with move semantics.

Effect on original feature: For vector, deque, and listthe fill value passed to resize is now passed by reference instead of by value, and an additional overload of resize has been added.

Valid C++ 2003 code that uses this function may fail to compile with this revision of C++.