###  | # Boost.Preprocessor ## Reference

Prev Next Macros Headers

# #include <boost/preprocessor/list/adt.hpp>

This header defines the fundamental list operations.

### Note

- The internal representation of lists is hidden. Although there aren't compelling reasons to change the representation, you should avoid writing code that depends on the internal representation details.

## #define BOOST_PP_LIST_CONS(H,T)

List constructor.

Lists are build using list constructors BOOST_PP_LIST_NIL and BOOST_PP_LIST_CONS(). For example,

      BOOST_PP_LIST_CONS(1,
      BOOST_PP_LIST_CONS(2,
      BOOST_PP_LIST_CONS(3,
      BOOST_PP_LIST_CONS(4,
      BOOST_PP_LIST_CONS(5,
      BOOST_PP_LIST_NIL)))))

Short lists can also be build from tuples:

      BOOST_PP_TUPLE_TO_LIST(5,(1,2,3,4,5))

Both of the above lists contain 5 elements: 1, 2, 3, 4 and 5.

Longer lists can be built with the help of BOOST_PP_LIST_APPEND().

## #define BOOST_PP_LIST_NIL

List nil constructor.

## #define BOOST_PP_LIST_IS_CONS(L)

Expands to 1 if the list is not nil and 0 otherwise.

## #define BOOST_PP_LIST_IS_NIL(L)

Expands to 1 if the list is nil and 0 otherwise.

## #define BOOST_PP_LIST_FIRST(L)

Expands to the first element of the list. The list must not be nil.

For example,

      BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE_TO_LIST(5,(1,2,3,4,5)))

expands to 1.

## #define BOOST_PP_LIST_REST(L)

Expands to a list of all but the first element of the list.

The list must not be nil.

For example,

      BOOST_PP_LIST_REST(BOOST_PP_TUPLE_TO_LIST(5,(1,2,3,4,5)))

expands to the same as:

      BOOST_PP_TUPLE_TO_LIST(4,(2,3,4,5))

Prev Next Macros Headers

Revised

© Copyright Housemarque Oy 2002

Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.