Sunday, June 3, 2012

c++ list reference

A list manages its elements as a doubly linked list (Figure below). As usual, the C++ standard library does not specify the kind of the implementation, but it follows from the list's name, constraints, and specifications.

Figure. Structure of a List

To use a list you must include the header file <list>[11] :

Note: In the original STL, the header file for lists was <list.h>.

#include <list>

There, the type is defined as a template class inside namespace std:

using namespace std {
   template <class T,
   class Allocator = allocator<T> >
   class list;

The elements of a list may have any type T that is assignable and copyable. The optional second template parameter defines the memory model. The default memory model is the model allocator, which is provided by the C++ standard library.

Note: In systems without support for default template parameters, the second argument is typically missing.

See Also:

No comments:

Post a Comment