|  | Home | Libraries | People | FAQ | More | 
        cons is a simple Forward
        Sequence. It is a lisp style recursive list structure where car is the head and
        cdr is the tail:
        usually another cons structure or nil:
        the empty list. Fusion's list is built on top of this more
        primitive data structure. 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).
      
#include <boost/fusion/container/list/cons.hpp> #include <boost/fusion/include/cons.hpp>
template <typename Car, typename Cdr = nil> struct cons;
| Parameter | Description | Default | 
|---|---|---|
| 
                   | Head type | |
| 
                   | Tail type | 
                   | 
Notation
nil
              An empty cons
            
C
              A cons type
            
l, l2
              Instances of cons
            
carAn arbitrary data
cdr
              Another cons list
            
sNSemantics of an expression is defined only where it differs from, or is not defined in Forward Sequence.
| Expression | Semantics | 
|---|---|
| 
                   | Creates an empty list. | 
| 
                   | Creates a cons with default constructed elements. | 
| 
                   | 
                  Creates a cons with  | 
| 
                   | 
                  Creates a cons with  | 
| 
                   | 
                  Copy constructs a cons from a Forward
                  Sequence,  | 
| 
                   | 
                  Assigns to a cons,  | 
| 
                   | 
                  The Nth element from the beginning of the sequence; see  | 
| ![[Note]](../../../../../../doc/src/images/note.png) | Note | 
|---|---|
| 
           | 
cons<int, cons<float> > l(12, cons<float>(5.5f)); std::cout <<at_c<0>(l) << std::endl; std::cout <<at_c<1>(l) << std::endl;