Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Annex C (informative) Compatibility [diff]

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

C.2.13 Clause [containers]: containers library [diff.cpp03.containers]

[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 International Standard. Adjusting containers such as std::list to the stricter requirements may require incompatible changes.

[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:

  • not all containers provide size(); use empty() instead of size() == 0;

  • not all containers are empty after construction (array);

  • not all containers have constant complexity for swap() (array).

[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.

[sequence.reqmts], [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:

  • erase(iter) for set, multiset, map, multimap

  • erase(begin, end) for set, multiset, map, multimap

  • insert(pos, num, val) for vector, deque, list, forward_list

  • insert(pos, beg, end) for vector, deque, list, forward_list

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 International Standard.

[sequence.reqmts], [associative.reqmts]
Change: Signature changes: from iterator to const_iterator parameters
Rationale: Overspecification. Effects: The signatures of the following member functions changed from taking an iterator to taking a const_iterator:

  • insert(iter, val) for vector, deque, list, set, multiset, map, multimap

  • insert(pos, beg, end) for vector, deque, list, forward_list

  • erase(iter) for set, multiset, map, multimap

  • erase(begin, end) for set, multiset, map, multimap

  • all forms of list::splice

  • all forms of list::merge

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

[sequence.reqmts], [associative.reqmts]
Change: Signature changes: resize
Rationale: Performance, compatibility with move semantics.
Effect on original feature: For vector, deque, and list the 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 International Standard.