1 # /* Copyright (C) 2001
\r
3 # * http://www.housemarque.com
\r
5 # * Distributed under the Boost Software License, Version 1.0. (See
\r
6 # * accompanying file LICENSE_1_0.txt or copy at
\r
7 # * http://www.boost.org/LICENSE_1_0.txt)
\r
10 # /* Revised by Paul Mensonides (2002) */
\r
12 # /* See http://www.boost.org for most recent version. */
\r
14 # ifndef BOOST_PREPROCESSOR_LIST_FIRST_N_HPP
\r
15 # define BOOST_PREPROCESSOR_LIST_FIRST_N_HPP
\r
17 # include <boost/preprocessor/arithmetic/dec.hpp>
\r
18 # include <boost/preprocessor/config/config.hpp>
\r
19 # include <boost/preprocessor/control/while.hpp>
\r
20 # include <boost/preprocessor/list/adt.hpp>
\r
21 # include <boost/preprocessor/list/reverse.hpp>
\r
22 # include <boost/preprocessor/tuple/elem.hpp>
\r
23 # include <boost/preprocessor/tuple/rem.hpp>
\r
25 # /* BOOST_PP_LIST_FIRST_N */
\r
27 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
\r
28 # define BOOST_PP_LIST_FIRST_N(count, list) BOOST_PP_LIST_REVERSE(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_WHILE(BOOST_PP_LIST_FIRST_N_P, BOOST_PP_LIST_FIRST_N_O, (count, list, BOOST_PP_NIL))))
\r
30 # define BOOST_PP_LIST_FIRST_N(count, list) BOOST_PP_LIST_FIRST_N_I(count, list)
\r
31 # define BOOST_PP_LIST_FIRST_N_I(count, list) BOOST_PP_LIST_REVERSE(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_WHILE(BOOST_PP_LIST_FIRST_N_P, BOOST_PP_LIST_FIRST_N_O, (count, list, BOOST_PP_NIL))))
\r
34 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
\r
35 # define BOOST_PP_LIST_FIRST_N_P(d, data) BOOST_PP_TUPLE_ELEM(3, 0, data)
\r
37 # define BOOST_PP_LIST_FIRST_N_P(d, data) BOOST_PP_LIST_FIRST_N_P_I data
\r
38 # define BOOST_PP_LIST_FIRST_N_P_I(c, l, nl) c
\r
41 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()
\r
42 # define BOOST_PP_LIST_FIRST_N_O(d, data) BOOST_PP_LIST_FIRST_N_O_D data
\r
44 # define BOOST_PP_LIST_FIRST_N_O(d, data) BOOST_PP_LIST_FIRST_N_O_D(BOOST_PP_TUPLE_ELEM(3, 0, data), BOOST_PP_TUPLE_ELEM(3, 1, data), BOOST_PP_TUPLE_ELEM(3, 2, data))
\r
47 # define BOOST_PP_LIST_FIRST_N_O_D(c, l, nl) (BOOST_PP_DEC(c), BOOST_PP_LIST_REST(l), (BOOST_PP_LIST_FIRST(l), nl))
\r
49 # /* BOOST_PP_LIST_FIRST_N_D */
\r
51 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
\r
52 # define BOOST_PP_LIST_FIRST_N_D(d, count, list) BOOST_PP_LIST_REVERSE_D(d, BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_LIST_FIRST_N_P, BOOST_PP_LIST_FIRST_N_O, (count, list, BOOST_PP_NIL))))
\r
54 # define BOOST_PP_LIST_FIRST_N_D(d, count, list) BOOST_PP_LIST_FIRST_N_D_I(d, count, list)
\r
55 # define BOOST_PP_LIST_FIRST_N_D_I(d, count, list) BOOST_PP_LIST_REVERSE_D(d, BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_WHILE_ ## d(BOOST_PP_LIST_FIRST_N_P, BOOST_PP_LIST_FIRST_N_O, (count, list, BOOST_PP_NIL))))
\r