1 # /* **************************************************************************
2 #  *                                                                          *
3 #  *     (C) Copyright Paul Mensonides 2002.
4 #  *     Distributed under the Boost Software License, Version 1.0. (See
5 #  *     accompanying file LICENSE_1_0.txt or copy at
6 #  *     http://www.boost.org/LICENSE_1_0.txt)
7 #  *                                                                          *
8 #  ************************************************************************** */
9 #
10 # /* See http://www.boost.org for most recent version. */
11 #
12 # ifndef BOOST_PREPROCESSOR_SEQ_REST_N_HPP
13 # define BOOST_PREPROCESSOR_SEQ_REST_N_HPP
14 #
15 # include <boost/preprocessor/arithmetic/inc.hpp>
16 # include <boost/preprocessor/comparison/not_equal.hpp>
17 # include <boost/preprocessor/config/config.hpp>
18 # include <boost/preprocessor/control/iif.hpp>
19 # include <boost/preprocessor/facilities/identity.hpp>
20 # include <boost/preprocessor/logical/bitand.hpp>
21 # include <boost/preprocessor/seq/detail/is_empty.hpp>
22 # include <boost/preprocessor/seq/detail/split.hpp>
23 # include <boost/preprocessor/tuple/elem.hpp>
24 #
25 # /* BOOST_PP_SEQ_REST_N */
26 #
27 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
28 #    define BOOST_PP_SEQ_REST_N(n, seq) BOOST_PP_SEQ_REST_N_DETAIL_EXEC(n, seq, BOOST_PP_SEQ_DETAIL_EMPTY_SIZE(seq))
29 # else
30 #    define BOOST_PP_SEQ_REST_N(n, seq) BOOST_PP_SEQ_REST_N_I(n, seq)
31 #    define BOOST_PP_SEQ_REST_N_I(n, seq) BOOST_PP_SEQ_REST_N_DETAIL_EXEC(n, seq, BOOST_PP_SEQ_DETAIL_EMPTY_SIZE(seq))
32 # endif
33 #
34 #    define BOOST_PP_SEQ_REST_N_DETAIL_EXEC_NO_MATCH(n, seq)
35 #    define BOOST_PP_SEQ_REST_N_DETAIL_EXEC_MATCH(n, seq) \
36             BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PP_SEQ_SPLIT(BOOST_PP_INC(n), BOOST_PP_IDENTITY( (nil) seq )))() \
37 /**/
38 #    define BOOST_PP_SEQ_REST_N_DETAIL_EXEC(n, seq, size) \
39         BOOST_PP_IIF \
40             ( \
41             BOOST_PP_BITAND \
42                 ( \
43                 BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY_SIZE(size), \
44                 BOOST_PP_NOT_EQUAL(n,size) \
45                 ), \
46             BOOST_PP_SEQ_REST_N_DETAIL_EXEC_MATCH, \
47             BOOST_PP_SEQ_REST_N_DETAIL_EXEC_NO_MATCH \
48             ) \
49         (n, seq)  \
50 /**/
51 #
52 # endif
53