[Type Name<T>]


Description

[A summary of a types properties example for the STL vector::]

A vector<T> is a Container supports random access to elements, constant time insertion and removal of elements at the end, and linear time insertion and removal of elements at the beginning or in the middle. The number of elements in a vector may vary dynamically; memory management is automatic. Vector is the simplest of the STL container classes, and in many cases the most efficient.

Template Parameters

[The template parameters of a class template usually must satisfy a set of requirements. Many of these can simply be expressed by listing which concept a template parameter must conform to, but some type requirements are slightly more complicated, and involve a relationship between two different template parameters. If the type is not a template and hence has no template parameters, this section can be skipped.]

ParameterDefaultType RequirementsDescription
TNone, except for those imposed by the requirements of Random Access Container and Back Insertion Sequence.

The value type. This is also defined as vector:::value_type

AllocallocAlloc is an Allocator.The set's allocator, used for all internal memory management.
...   

Model of

[A list of the concepts that this type is a model of, and links to those concepts. Note that a type may be a model of more than one concept. If a type is a model of two different concepts, that simply means that it satisfies the requirements of both. if the type fails to model any pre-existing concept, this section may be skipped.]

Random Access Container, Back Insertion Sequence.

Derived From

[If this class inherits from any other classes, they are listed in this section.]

Notation

[The next two sections, associated types and valid expressions, present expressions involving types that model the concept being defined. This section defines the meaning of the variables and identifiers used in those expressions.]

SymbolDescription
XA type that is a model of the [Concept Name]
x, a, bAn object of type X
Ta type that is a model of the parameter type
... 

Associated Types

[A concept is a set of requirements on some type. Frequently, however, some of those requirements involve some other type. For example, one of the Unary Function requirements is that a Unary Function must have an argument type; if F is a type that models Unary Function and f is an object of type F, then, in the expression f(x), x must be of F's argument type. If a concept does not have any such associated types this section can be eliminated.]

TypeDescription
X::value_typeA type of an object stored in [Concept Name]. Same as T
X::iteratorAn object of type X
... 

Inherited Valid Expressions (Optional)

[A type will support all the operations of the concept which the type models. In addition, it will support all the functions which are declared in any public base classes. All these valid expressions may be listed here. The reason that this section is optional is that listing all the valid expressions implemented by base clases and other concepts can be long, tedious and redundant. On the other hand, following links back to the concepts and/or base class can also sometimes be tedious so it's hard to make a hard and fast rule]

New Valid Expressions

In addition to the expressions defined in Random Access Container and Back Insertion Sequence the following expressions must be valid for any object v of type vector<T> .

ExpressionType RequirementsReturn TypeSemantics
v.capacity() size_typeNumber of elements for which memory has been allocated. capacity() is always greater than or equal to size(). [2] [3]
v.reserve(size_type n) voidIf n is less than or equal to capacity(), this call has no effect. Otherwise, it is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to n; otherwise, capacity() is unchanged. In either case, size() is unchanged. [2] [4]
...(only for templates)  

Header

[A link to the source code where the type is defined.]

#include <vector>

Example of use

[A code fragment involving the type.]

#include <vector>

vector<int> V;
V.insert(V.begin(), 3);
assert(V.size() == 1 && V.capacity() >= 1 && V[0] == 3);

Notes

[Footnotes (if any) that are referred to by other parts of the page.]

See Also

[links to any other related concepts or types]

There are 0 comments and replies

Comment on This Page