1 # /* Copyright (C) 2001
3 # * http://www.housemarque.com
5 # * Permission to copy, use, modify, sell and distribute this software is
6 # * granted provided this copyright notice appears in all copies. This
7 # * software is provided "as is" without express or implied warranty, and
8 # * with no claim as to its suitability for any purpose.
11 # /* Revised by Paul Mensonides (2002) */
13 # /* See http://www.boost.org for most recent version. */
15 # ifndef BOOST_PREPROCESSOR_LIST_FIRST_N_HPP
16 # define BOOST_PREPROCESSOR_LIST_FIRST_N_HPP
18 # include <boost/preprocessor/arithmetic/dec.hpp>
19 # include <boost/preprocessor/config/config.hpp>
20 # include <boost/preprocessor/control/while.hpp>
21 # include <boost/preprocessor/list/adt.hpp>
22 # include <boost/preprocessor/list/reverse.hpp>
23 # include <boost/preprocessor/tuple/elem.hpp>
24 # include <boost/preprocessor/tuple/rem.hpp>
26 # /* BOOST_PP_LIST_FIRST_N */
28 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
29 # 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))))
31 # define BOOST_PP_LIST_FIRST_N(count, list) BOOST_PP_LIST_FIRST_N_I(count, list)
32 # 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))))
35 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
36 # define BOOST_PP_LIST_FIRST_N_P(d, data) BOOST_PP_TUPLE_ELEM(3, 0, data)
38 # define BOOST_PP_LIST_FIRST_N_P(d, data) BOOST_PP_LIST_FIRST_N_P_I data
39 # define BOOST_PP_LIST_FIRST_N_P_I(c, l, nl) c
42 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()
43 # define BOOST_PP_LIST_FIRST_N_O(d, data) BOOST_PP_LIST_FIRST_N_O_D data
45 # 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))
48 # 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))
50 # /* BOOST_PP_LIST_FIRST_N_D */
52 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
53 # 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))))
55 # define BOOST_PP_LIST_FIRST_N_D(d, count, list) BOOST_PP_LIST_FIRST_N_D_I(d, count, list)
56 # 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))))