Storage concept

Storage concept

Description

Storage is a variable-size container whose elements are arranged in a strict linear order.

Storage extends the STL Container concept with some STL Sequence-like functionality. The main difference with
the Sequence concept however is that the Storage concept does not require default-initialisation of its
elements.

Expression semantics

Name

Expression

Precondition

Semantics

Postcondition

Default-constructor

X()

Creates 0 elements.

size()==0

Size-constructor

X(n)

n>=0

Creates n elements. Elements are constructed without an initializer. That is
if T is a (possibly cv-qualified) non-POD class type (or array thereof), the object is default
initialized. Otherwise, the object created has indeterminate value. See the sentance
"If new initializer is omitted" in section 5.3.4 paragraph 15 of the ISO C++ standard.

size()==n

Fill-constructor

X(n,t)

n>=0

Creates n initialised element with copies of t

size()==n

Range constructor

X(i, j)

[i,j) is a valid range.

copies the range [i,j) to the storage

size() is equal to the distance from i to j. Each element is a copy of the corresponding element in the range [i,j).

Resize

a.resize(n, t)

n <= a.max_size()

Modified the container so that it has exactly n elements.
The container may be reallocated if its size changes.
Existing element values are preserved, additional elements are copies of t.

a.size() == n

Resize

a.resize(n)

n <= a.max_size()

Modified the container so that it has exactly n elements.
The container may be reallocated if its size changes. Element values are uninitialised. That is,
each element value may be a previously assigned value or default construced value for T.