Added list data structure

[SVN r12431]
This commit is contained in:
Vesa Karvonen
2002-01-22 10:18:08 +00:00
parent e562e2478b
commit 0206bbaa60
21 changed files with 814 additions and 2 deletions

View File

@ -0,0 +1,30 @@
#ifndef BOOST_PREPROCESSOR_LIST_HPP
#define BOOST_PREPROCESSOR_LIST_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list.hpp">Click here to see the header.</a>
Includes all list headers.
*/
#include <boost/preprocessor/list/append.hpp>
#include <boost/preprocessor/list/at.hpp>
#include <boost/preprocessor/list/cat.hpp>
#include <boost/preprocessor/list/filter.hpp>
#include <boost/preprocessor/list/first_n.hpp>
#include <boost/preprocessor/list/size.hpp>
#include <boost/preprocessor/list/to_tuple.hpp>
#include <boost/preprocessor/list/transform.hpp>
#endif

View File

@ -0,0 +1,98 @@
#ifndef BOOST_PREPROCESSOR_LIST_ADT_HPP
#define BOOST_PREPROCESSOR_LIST_ADT_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/adt.hpp">Click here to see the header.</a>
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.
*/
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/preprocessor/logical/not.hpp>
//! List constructor.
/*!
Lists are build using list constructors BOOST_PP_LIST_NIL and
BOOST_PP_LIST_CONS(). For example,
<PRE>\verbatim
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)))))
\endverbatim</PRE>
Short lists can also be build from tuples:
<PRE>\verbatim
BOOST_PP_TUPLE_TO_LIST(5,(1,2,3,4,5))
\endverbatim</PRE>
Both of the above lists contain 5 elements: 1, 2, 3, 4 and 5.
*/
#define BOOST_PP_LIST_CONS(H,T) (H,T,1)
//! List nil constructor.
/*!
See BOOST_PP_LIST_CONS().
*/
#define BOOST_PP_LIST_NIL (_,_,0)
//! Expands to 1 if the list is not nil and 0 otherwise.
/*!
See BOOST_PP_LIST_IS_NIL().
*/
#define BOOST_PP_LIST_IS_CONS(L) BOOST_PP_TUPLE_ELEM(3,2,L)
//! Expands to 1 if the list is nil and 0 otherwise.
/*!
See BOOST_PP_LIST_IS_CONS().
*/
#define BOOST_PP_LIST_IS_NIL(L) BOOST_PP_NOT(BOOST_PP_TUPLE_ELEM(3,2,L))
//! Expands to the first element of the list. The list must not be nil.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE_TO_LIST(5,(1,2,3,4,5)))
\endverbatim</PRE>
expands to 1.
See BOOST_PP_LIST_REST().
*/
#define BOOST_PP_LIST_FIRST(L) BOOST_PP_TUPLE_ELEM(3,0,L)
//! Expands to a list of all but the first element of the list. The list must not be nil.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_REST(BOOST_PP_TUPLE_TO_LIST(5,(1,2,3,4,5)))
\endverbatim</PRE>
expands to a list containing 2, 3, 4 and 5.
See BOOST_PP_LIST_FIRST().
*/
#define BOOST_PP_LIST_REST(L) BOOST_PP_TUPLE_ELEM(3,1,L)
#endif

View File

@ -0,0 +1,41 @@
#ifndef BOOST_PREPROCESSOR_LIST_APPEND_HPP
#define BOOST_PREPROCESSOR_LIST_APPEND_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/append.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/list/fold_right.hpp>
//! Catenates two lists together.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_APPEND
( BOOST_PP_TUPLE_TO_LIST(2,(1,2))
, BOOST_PP_TUPLE_TO_LIST(2,(3,4))
)
\endverbatim</PRE>
produces a list containing 1, 2, 3 and 4.
*/
#define BOOST_PP_LIST_APPEND(L,P) BOOST_PP_LIST_APPEND_D(0,L,P)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_APPEND_D(D,L,P) BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_APPEND_F,L,P)
#define BOOST_PP_LIST_APPEND_F(D,H,P) BOOST_PP_LIST_CONS(H,P)
#endif
#endif

View File

@ -0,0 +1,37 @@
#ifndef BOOST_PFIRST_NPROCESSOR_LIST_AT_HPP
#define BOOST_PFIRST_NPROCESSOR_LIST_AT_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this softwaFIRST_N is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/at.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/list/rest_n.hpp>
//! Expands to the I:th element of the list L. The first element is at index 0.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_AT(BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)),1)
\endverbatim</PRE>
expands to B.
*/
#define BOOST_PP_LIST_AT(L,I) BOOST_PP_LIST_AT_D(0,L,I)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_AT_D(D,L,I) BOOST_PP_LIST_FIRST(BOOST_PP_LIST_REST_N_D(D,I,L))
#endif
#endif

View File

@ -0,0 +1,39 @@
#ifndef BOOST_PREPROCESSOR_LIST_CAT_HPP
#define BOOST_PREPROCESSOR_LIST_CAT_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/cat.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/list/fold_left.hpp>
//! Catenates all elements of the list.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_CAT(BOOST_PP_TUPLE_TO_LIST(3,(1,2,3)))
\endverbatim</PRE>
expands to 123.
*/
#define BOOST_PP_LIST_CAT(L) BOOST_PP_LIST_CAT_D(0,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_CAT_D(D,L) BOOST_PP_LIST_FOLD_LEFT_D(D,BOOST_PP_LIST_CAT_F,BOOST_PP_LIST_FIRST(L),BOOST_PP_LIST_REST(L))
#define BOOST_PP_LIST_CAT_F(D,P,H) BOOST_PP_CAT(P,H)
#endif
#endif

View File

@ -0,0 +1,43 @@
#ifndef BOOST_PREPROCESSOR_LIST_ENUM_HPP
#define BOOST_PREPROCESSOR_LIST_ENUM_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/enum.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/comma_if.hpp>
#include <boost/preprocessor/list/for_each.hpp>
//! Converts the list to a comma separated list.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_ENUM(BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
\endverbatim</PRE>
expands to:
<PRE>\verbatim
A, B, C
\endverbatim</PRE>
*/
#define BOOST_PP_LIST_ENUM(L) BOOST_PP_LIST_ENUM_R(0,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_ENUM_R(R,L) BOOST_PP_LIST_FOR_EACH_R(R,BOOST_PP_LIST_ENUM_F,_,L)
#define BOOST_PP_LIST_ENUM_F(I,_,X) BOOST_PP_COMMA_IF(I) X
#endif
#endif

View File

@ -0,0 +1,38 @@
#ifndef BOOST_PREPROCESSOR_LIST_FILTER_HPP
#define BOOST_PREPROCESSOR_LIST_FILTER_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/filter.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/list/fold_right.hpp>
//! Expands to a list containing all the elements X of the list for which F(D,P,X) is true.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_FILTER(BOOST_PP_NOT_EQUAL_D,2,BOOST_PP_TUPLE_TO_LIST(3,(1,2,3)))
\endverbatim</PRE>
expands to a list containing 1 and 3.
*/
#define BOOST_PP_LIST_FILTER(F,P,L) BOOST_PP_LIST_FILTER_D(0,F,P,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_FILTER_D(D,F,P,L) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_FILTER_F,L,(F,P,BOOST_PP_LIST_NIL)))
#define BOOST_PP_LIST_FILTER_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE_ELEM(3,1,P),BOOST_PP_IF(BOOST_PP_TUPLE_ELEM(3,0,P)(D,BOOST_PP_TUPLE_ELEM(3,1,P),H),BOOST_PP_LIST_CONS,BOOST_PP_TUPLE2_ELEM1)(H,BOOST_PP_TUPLE_ELEM(3,2,P)))
#endif
#endif

View File

@ -0,0 +1,41 @@
#ifndef BOOST_PREPROCESSOR_LIST_FIRST_N_HPP
#define BOOST_PREPROCESSOR_LIST_FIRST_N_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/first_n.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/dec.hpp>
#include <boost/preprocessor/list/adt.hpp>
#include <boost/preprocessor/while.hpp>
//! Expands to a list of the first N elements of the list.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_FIRST_N(2,BOOST_PP_TUPLE_TO_LIST(4,(+,-,*,/)))
\endverbatim</PRE>
expands to a list containing + and -.
*/
#define BOOST_PP_LIST_FIRST_N(N,L) BOOST_PP_LIST_FIRST_N_D(0,N,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_FIRST_N_D(D,N,L) BOOST_PP_LIST_REVERSE_D(D,BOOST_PP_TUPLE_ELEM(3,0,BOOST_PP_WHILE##D(BOOST_PP_LIST_FIRST_N_C,BOOST_PP_LIST_FIRST_N_F,(BOOST_PP_LIST_NIL,L,N))))
#define BOOST_PP_LIST_FIRST_N_C(D,X) BOOST_PP_TUPLE_ELEM(3,2,X)
#define BOOST_PP_LIST_FIRST_N_F(D,X) (BOOST_PP_LIST_CONS(BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE_ELEM(3,1,X)),BOOST_PP_TUPLE_ELEM(3,0,X)),BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(3,1,X)),BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(3,2,X)))
#endif
#endif

View File

@ -0,0 +1,53 @@
#ifndef BOOST_PREPROCESSOR_LIST_FOLD_LEFT_HPP
#define BOOST_PREPROCESSOR_LIST_FOLD_LEFT_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/fold_left.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/list/adt.hpp>
#include <boost/preprocessor/while.hpp>
//! Iterates F(D,P,X) for each element X of the list L (from the left or the start of the list).
/*!
In other words,
<PRE>\verbatim
BOOST_PP_LIST_FOLD_LEFT(F,P,L)
\endverbatim</PRE>
expands to:
<PRE>\verbatim
F
( D
, ... F(D, F(D,P,BOOST_PP_LIST_AT(L,0)), BOOST_PP_LIST_AT(L,1)) ...
, BOOST_PP_LIST_AT(L,BOOST_PP_DEC(BOOST_PP_LIST_SIZE(L))
)
\endverbatim</PRE>
Note that folding, or accumulation, is a very general pattern of computation.
Most list operations can implemented in terms of folding.
See BOOST_PP_LIST_FOLD_RIGHT().
*/
#define BOOST_PP_LIST_FOLD_LEFT(F,P,L) BOOST_PP_LIST_FOLD_LEFT_D(0,F,P,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_FOLD_LEFT_D(D,F,P,L) BOOST_PP_TUPLE_ELEM(3,1,BOOST_PP_WHILE##D(BOOST_PP_LIST_FOLD_LEFT_C,BOOST_PP_LIST_FOLD_LEFT_F,(F,P,L)))
#define BOOST_PP_LIST_FOLD_LEFT_C(D,X) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(3,2,X))
#define BOOST_PP_LIST_FOLD_LEFT_F(D,X) (BOOST_PP_TUPLE_ELEM(3,0,X),BOOST_PP_TUPLE_ELEM(3,0,X)(D,BOOST_PP_TUPLE_ELEM(3,1,X),BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE_ELEM(3,2,X))),BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(3,2,X)))
#endif
#endif

View File

@ -0,0 +1,56 @@
#ifndef BOOST_PREPROCESSOR_LIST_FOLD_RIGHT_HPP
#define BOOST_PREPROCESSOR_LIST_FOLD_RIGHT_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/fold_right.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/list/reverse.hpp>
//! Iterates F(D,X,P) for each element X of the list L (from the right or the end of the list).
/*!
In other words,
<PRE>\verbatim
BOOST_PP_LIST_FOLD_RIGHT(F,L,P)
\endverbatim</PRE>
expands to:
<PRE>\verbatim
F
( D
, BOOST_PP_LIST_AT(L,0)
, ... F
( D
, BOOST_PP_LIST_AT(L,BOOST_PP_SUB(BOOST_PP_LIST_SIZE(L),2))
, F
( D
, BOOST_PP_LIST_AT(L,BOOST_PP_SUB(BOOST_PP_LIST_SIZE(L),1))
, P
)
) ...
)
\endverbatim</PRE>
See BOOST_PP_LIST_FOLD_LEFT().
*/
#define BOOST_PP_LIST_FOLD_RIGHT(F,L,P) BOOST_PP_LIST_FOLD_RIGHT_D(0,F,L,P)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_FOLD_RIGHT_D(D,F,L,P) BOOST_PP_TUPLE_ELEM(2,1,BOOST_PP_LIST_FOLD_LEFT_D(D,BOOST_PP_LIST_FOLD_RIGHT_F,(F,P),BOOST_PP_LIST_REVERSE_D(D,L)))
#define BOOST_PP_LIST_FOLD_RIGHT_F(D,FR,H) (BOOST_PP_TUPLE_ELEM(2,0,FR),BOOST_PP_TUPLE_ELEM(2,0,FR)(D,H,BOOST_PP_TUPLE_ELEM(2,1,FR)))
#endif
#endif

View File

@ -0,0 +1,44 @@
#ifndef BOOST_PREPROCESSOR_LIST_FOR_EACH_HPP
#define BOOST_PREPROCESSOR_LIST_FOR_EACH_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/for_each.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/list/adt.hpp>
#include <boost/preprocessor/for.hpp>
//! Repeats F(R,P,BOOST_PP_LIST_AT(L,I)) for each I = [0,BOOST_PP_LIST_SIZE(L)[.
/*!
In other words, expands to the sequence:
<PRE>\verbatim
F(R,P,BOOST_PP_LIST_AT(L,0))
F(R,P,BOOST_PP_LIST_AT(L,1))
...
F(R,P,BOOST_PP_LIST_AT(L,BOOST_PP_DEC(BOOST_PP_LIST_SIZE(L))))
\endverbatim</PRE>
See BOOST_PP_FOR() for an explanation of the R parameter.
*/
#define BOOST_PP_LIST_FOR_EACH(F,P,L) BOOST_PP_LIST_FOR_EACH_R(0,F,P,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_FOR_EACH_R(R,F,P,L) BOOST_PP_FOR##R((F,P,L,0),BOOST_PP_LIST_FOR_EACH_C,BOOST_PP_LIST_FOR_EACH_F,BOOST_PP_LIST_FOR_EACH_I)
#define BOOST_PP_LIST_FOR_EACH_C(R,FPL) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(4,2,FPL))
#define BOOST_PP_LIST_FOR_EACH_F(R,FPL) (BOOST_PP_TUPLE_ELEM(4,0,FPL),BOOST_PP_TUPLE_ELEM(4,1,FPL),BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(4,2,FPL)),BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4,3,FPL)))
#define BOOST_PP_LIST_FOR_EACH_I(R,FPL) BOOST_PP_EXPAND(BOOST_PP_TUPLE_ELEM(4,0,FPL)(BOOST_PP_TUPLE_ELEM(4,3,FPL),BOOST_PP_TUPLE_ELEM(4,1,FPL),BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE_ELEM(4,2,FPL))))
#endif
#endif

View File

@ -0,0 +1,41 @@
#ifndef BOOST_PREPROCESSOR_LIST_REST_N_HPP
#define BOOST_PREPROCESSOR_LIST_REST_N_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/rest_n.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/dec.hpp>
#include <boost/preprocessor/list/adt.hpp>
#include <boost/preprocessor/while.hpp>
//! Expands to a list of all but the first N elements of the list.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_REST_N(2,BOOST_PP_TUPLE_TO_LIST(4,(+,-,*,/)))
\endverbatim</PRE>
expands to a list containing * and /.
*/
#define BOOST_PP_LIST_REST_N(N,L) BOOST_PP_LIST_REST_N_D(0,N,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_REST_N_D(D,N,L) BOOST_PP_TUPLE_ELEM(2,0,BOOST_PP_WHILE##D(BOOST_PP_LIST_REST_N_C,BOOST_PP_LIST_REST_N_F,(L,N)))
#define BOOST_PP_LIST_REST_N_C(D,X) BOOST_PP_TUPLE_ELEM(2,1,X)
#define BOOST_PP_LIST_REST_N_F(D,X) (BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(2,0,X)),BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(2,1,X)))
#endif
#endif

View File

@ -0,0 +1,38 @@
#ifndef BOOST_PREPROCESSOR_LIST_REVERSE_HPP
#define BOOST_PREPROCESSOR_LIST_REVERSE_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/reverse.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/list/fold_left.hpp>
//! List reversal.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_REVERSE(BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
\endverbatim</PRE>
expands to a list containing C, B and A.
*/
#define BOOST_PP_LIST_REVERSE(L) BOOST_PP_LIST_REVERSE_D(0,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_REVERSE_D(D,L) BOOST_PP_LIST_FOLD_LEFT_D(D,BOOST_PP_LIST_REVERSE_F,BOOST_PP_LIST_NIL,L)
#define BOOST_PP_LIST_REVERSE_F(D,P,H) BOOST_PP_LIST_CONS(H,P)
#endif
#endif

View File

@ -0,0 +1,39 @@
#ifndef BOOST_PREPROCESSOR_LIST_SIZE_HPP
#define BOOST_PREPROCESSOR_LIST_SIZE_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/size.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/list/fold_left.hpp>
#include <boost/preprocessor/inc.hpp>
//! Expands to the number of elements in the list.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_SIZE(BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
\endverbatim</PRE>
expands to 3.
*/
#define BOOST_PP_LIST_SIZE(L) BOOST_PP_LIST_SIZE_D(0,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_SIZE_D(D,L) BOOST_PP_LIST_FOLD_LEFT_D(D,BOOST_PP_LIST_SIZE_F,0,L)
#define BOOST_PP_LIST_SIZE_F(D,P,H) BOOST_PP_INC(P)
#endif
#endif

View File

@ -0,0 +1,41 @@
#ifndef BOOST_PREPROCESSOR_LIST_TO_TUPLE_HPP
#define BOOST_PREPROCESSOR_LIST_TO_TUPLE_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/to_tuple.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/comma_if.hpp>
#include <boost/preprocessor/list/enum.hpp>
//! Converts the list to a tuple.
/*!
For example,
<PRE>\verbatim
BOOST_PP_LIST_TO_TUPLE(BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
\endverbatim</PRE>
expands to (A,B,C).
NOTE: The supported size of the list being converted to a tuple is limited by
BOOST_PP_LIMIT_MAG rather than BOOST_PP_LIMIT_TUPLE.
*/
#define BOOST_PP_LIST_TO_TUPLE(L) BOOST_PP_LIST_TO_TUPLE_R(0,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_TO_TUPLE_R(D,L) (BOOST_PP_LIST_ENUM_R(D,L))
#endif
#endif

View File

@ -0,0 +1,48 @@
#ifndef BOOST_PREPROCESSOR_LIST_TRANSFORM_HPP
#define BOOST_PREPROCESSOR_LIST_TRANSFORM_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/list/transform.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/list/fold_right.hpp>
//! Applies the macro F(D,P,X) to each element X of the list producing a new list.
/*!
In other words, BOOST_PP_LIST_TRANSFORM(F,P,L) expands to same as:
<PRE>\verbatim
BOOST_PP_LIST_CONS(F(D,P,BOOST_PP_LIST_AT(L,0)),
BOOST_PP_LIST_CONS(F(D,P,BOOST_PP_LIST_AT(L,1)),
...
BOOST_PP_LIST_CONS(F(D,P,BOOST_PP_LIST_AT(L,BOOST_PP_DEC(BOOST_PP_LIST_SIZE(L)))),
BOOST_PP_LIST_NIL) ... ))
\endverbatim</PRE>
For example,
<PRE>\verbatim
BOOST_PP_LIST_TRANSFORM(BOOST_PP_ADD_D,2,BOOST_PP_TUPLE_TO_LIST(2,(1,2)))
\endverbatim</PRE>
expands to a list containing 3 and 4.
*/
#define BOOST_PP_LIST_TRANSFORM(F,P,L) BOOST_PP_LIST_TRANSFORM_D(0,F,P,L)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_LIST_TRANSFORM_D(D,F,P,L) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_TRANSFORM_F,L,(F,P,BOOST_PP_LIST_NIL)))
#define BOOST_PP_LIST_TRANSFORM_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE_ELEM(3,1,P),BOOST_PP_LIST_CONS(BOOST_PP_EXPAND(BOOST_PP_TUPLE_ELEM(3,0,P)(D,BOOST_PP_TUPLE_ELEM(3,1,P),H)),BOOST_PP_TUPLE_ELEM(3,2,P)))
#endif
#endif

View File

@ -79,7 +79,7 @@ Since recursive expansion of macros is not allowed by the C++ preprocessor,
replacing the BOOST_PP_REPEAT_2ND above with BOOST_PP_REPEAT, would not
produce the above expansion.
See also BOOST_PP_FOR().
See BOOST_PP_FOR().
*/
#define BOOST_PP_REPEAT(N,M,P) BOOST_PP_REPEAT_DELAY(N,M,P)

View File

@ -21,4 +21,5 @@ Includes all tuple headers.
#include <boost/preprocessor/tuple/eat.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/preprocessor/tuple/to_list.hpp>
#endif

View File

@ -39,7 +39,7 @@ Examples of tuples:
4-tuple: (A B C, D, EF, 34)
\endverbatim</PRE>
See also BOOST_PP_LIMIT_TUPLE.
See BOOST_PP_LIMIT_TUPLE.
*/
#define BOOST_PP_TUPLE_ELEM(N,I,T) BOOST_PP_TUPLE_ELEM_DELAY(N,I,T)

View File

@ -0,0 +1,42 @@
#ifndef BOOST_PREPROCESSOR_TUPLE_TO_LIST_HPP
#define BOOST_PREPROCESSOR_TUPLE_TO_LIST_HPP
// Copyright (C) 2001
// Housemarque Oy
// http://www.housemarque.com
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version.
/*! \file
<a href="../../../../boost/preprocessor/tuple/to_list.hpp">Click here to see the header.</a>
*/
#include <boost/preprocessor/list/adt.hpp>
//! Converts a tuple to a list.
/*!
See BOOST_PP_LIST_CONS() for an example.
See BOOST_PP_LIMIT_TUPLE.
*/
#define BOOST_PP_TUPLE_TO_LIST(N,T) BOOST_PP_TUPLE_TO_LIST_DELAY(N,T)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define BOOST_PP_TUPLE_TO_LIST_DELAY(N,T) BOOST_PP_TUPLE##N##_TO_LIST T
#define BOOST_PP_TUPLE0_TO_LIST() BOOST_PP_LIST_NIL
#define BOOST_PP_TUPLE1_TO_LIST(A) BOOST_PP_LIST_CONS(A,BOOST_PP_LIST_NIL)
#define BOOST_PP_TUPLE2_TO_LIST(A,B) BOOST_PP_LIST_CONS(A,BOOST_PP_TUPLE1_TO_LIST(B))
#define BOOST_PP_TUPLE3_TO_LIST(A,B,C) BOOST_PP_LIST_CONS(A,BOOST_PP_TUPLE2_TO_LIST(B,C))
#define BOOST_PP_TUPLE4_TO_LIST(A,B,C,D) BOOST_PP_LIST_CONS(A,BOOST_PP_TUPLE3_TO_LIST(B,C,D))
#define BOOST_PP_TUPLE5_TO_LIST(A,B,C,D,E) BOOST_PP_LIST_CONS(A,BOOST_PP_TUPLE4_TO_LIST(B,C,D,E))
#define BOOST_PP_TUPLE6_TO_LIST(A,B,C,D,E,F) BOOST_PP_LIST_CONS(A,BOOST_PP_TUPLE5_TO_LIST(B,C,D,E,F))
#define BOOST_PP_TUPLE7_TO_LIST(A,B,C,D,E,F,G) BOOST_PP_LIST_CONS(A,BOOST_PP_TUPLE6_TO_LIST(B,C,D,E,F,G))
#define BOOST_PP_TUPLE8_TO_LIST(A,B,C,D,E,F,G,H) BOOST_PP_LIST_CONS(A,BOOST_PP_TUPLE7_TO_LIST(B,C,D,E,F,G,H))
#endif
#endif