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.

Refinement of

Random Access Container and Default Constructible

Associated types

No additional types beyond those defined by Random Access Container

Notation

XA type that is model of Storage
TThe value_type of X
tAn object of type T
nobject of type convertible to X::size_type

Definitions

Valid expressions

In addition to the expressions defined in Random Access Container, and Default Constructible the following expressions must be valid:
NameExpressionType requirementsReturn type
Size constructor X(n) T is DefaultConstructible X
Fill constructor X(n,t) X
Range constructor X(i, j) i and j are Input Iterators whose value type is convertible to T X
Resize a.resize(n, t) a is mutable void
Resize a.resize(n) a is mutable void

Expression semantics

NameExpressionPreconditionSemanticsPostcondition
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.
a.size() == n

Complexity guarantees

Invariants

Models

Notes


Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt ).