Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

list

Description

list is a Forward Sequence of heterogenous typed data built on top of cons. It is more efficient than vector when the target sequence is constructed piecemeal (a data at a time). The runtime cost of access to each element is peculiarly constant (see Recursive Inlined Functions).

Header
#include <boost/fusion/sequence/container/list.hpp>
#include <boost/fusion/sequence/container/list/list_forward.hpp>
Synopsis
template <
    typename T0 = unspecified
  , typename T1 = unspecified
  , typename T2 = unspecified
    ...
  , typename TN = unspecified
>
struct list;

The variadic class interface accepts 0 to FUSION_MAX_LIST_SIZE elements, where FUSION_MAX_LIST_SIZE is a user definable predefined maximum that defaults to 10. Example:

list<int, char, double>

You may define the preprocessor constant FUSION_MAX_LIST_SIZE before including any Fusion header to change the default. Example:

#define FUSION_MAX_LIST_SIZE 20
Template parameters
Parameter Description Default
T0...TN Element types unspecified-type
Model of

Notation

L
A list type
l
An instance of list
e0...en
Heterogeneous values
s
A Forward Sequence
N
An Integral Constant
Expression Semantics

Semantics of an expression is defined only where it differs from, or is not defined in Forward Sequence.

Expression Semantics
L() Creates a list with default constructed elements.
L(e0, e1,... en) Creates a list with elements e0...en.
L(s) Copy constructs a list from a Forward Sequence, s.
l = s Assigns to a list, l, from a Forward Sequence, s.
at<N>(l) The Nth element from the beginning of the sequence; see at.

note at<n>(l) is provided for convenience and compatibility with the original Boost.Tuple library, despite list being a Forward Sequence only (at is supposed to be a Random Access Sequence requirement). The runtime complexity of at is constant (see Recursive Inlined Functions).

Example
list<int, float> l(12, 5.5f);
std::cout << at<0>(l) << std::endl;
std::cout << at<1>(l) << std::endl;
Copyright © 2001-2005 Joel de Guzman, Dan Marsden

PrevUpHomeNext