[diff.cpp03.containers]

# Annex C (informative) Compatibility [[diff]](./#diff)

## C.6 C++ and ISO C++ 2003 [[diff.cpp03]](diff.cpp03#containers)

### C.6.12 [[containers]](containers "23 Containers library"): containers library [diff.cpp03.containers]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2557)

**Affected subclause:** [[container.requirements]](container.requirements)  


**Change:** Complexity of size() member functions now constant[.](#1.sentence-1)

  


**Rationale:** Lack of specification of complexity of size() resulted in
divergent implementations with inconsistent performance characteristics[.](#1.sentence-2)

  


**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++[.](#1.sentence-3)

Adjusting
containers such as std​::​list to the stricter requirements may require
incompatible changes[.](#1.sentence-4)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2569)

**Affected subclause:** [[container.requirements]](container.requirements)  


**Change:** Requirements change: relaxation[.](#2.sentence-1)

  


**Rationale:** Clarification[.](#2.sentence-2)

  


**Effect on original feature:** Valid C++ 2003 code that attempts to meet the specified container requirements
may now be over-specified[.](#2.sentence-3)

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

- [(2.1)](#2.1)

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

- [(2.2)](#2.2)

not all containers are empty after construction (array);

- [(2.3)](#2.3)

not all containers have constant complexity for swap() (array)[.](#2.sentence-4)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2585)

**Affected subclause:** [[container.requirements]](container.requirements)  


**Change:** Requirements change: default constructible[.](#3.sentence-1)

  


**Rationale:** Clarification of container requirements[.](#3.sentence-2)

  


**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[.](#3.sentence-3)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2594)

**Affected subclauses:** [[sequence.reqmts]](sequence.reqmts) and [[associative.reqmts]](associative.reqmts)  


**Change:** Signature changes: from void return types[.](#4.sentence-1)

  


**Rationale:** Old signature threw away useful information that may be expensive
to recalculate[.](#4.sentence-2)

  


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

- [(4.1)](#4.1)

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

- [(4.2)](#4.2)

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

- [(4.3)](#4.3)

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

- [(4.4)](#4.4)

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 revision of C++[.](#4.sentence-4)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2613)

**Affected subclauses:** [[sequence.reqmts]](sequence.reqmts) and [[associative.reqmts]](associative.reqmts)  


**Change:** Signature changes: from iterator to const_iterator parameters[.](#5.sentence-1)

  


**Rationale:** Overspecification[.](#5.sentence-2)

  


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

- [(5.1)](#5.1)

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

- [(5.2)](#5.2)

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

- [(5.3)](#5.3)

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

- [(5.4)](#5.4)

all forms of list​::​splice

- [(5.5)](#5.5)

all forms of list​::​merge

Valid C++ 2003 code that uses these functions may fail to compile with this
revision of C++[.](#5.sentence-4)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L2635)

**Affected subclauses:** [[sequence.reqmts]](sequence.reqmts) and [[associative.reqmts]](associative.reqmts)  


**Change:** Signature changes: resize[.](#6.sentence-1)

  


**Rationale:** Performance, compatibility with move semantics[.](#6.sentence-2)

  


**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[.](#6.sentence-3)

Valid
C++ 2003 code that uses this function may fail to compile with this revision of C++[.](#6.sentence-4)
