Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:14

0001 /*=============================================================================
0002     Copyright (c) 2014 Paul Fultz II
0003     pp.h
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 
0008 #ifndef BOOST_HOF_GUARD_PP_H
0009 #define BOOST_HOF_GUARD_PP_H
0010 
0011 #define BOOST_HOF_PP_CAT(x, y) BOOST_HOF_PP_PRIMITIVE_CAT(x, y)
0012 #define BOOST_HOF_PP_PRIMITIVE_CAT(x, y) x ## y
0013 
0014 #define BOOST_HOF_PP_SEQ_ITERATE(...) BOOST_HOF_PP_PRIMITIVE_SEQ_ITERATE(__VA_ARGS__)
0015 #define BOOST_HOF_PP_PRIMITIVE_SEQ_ITERATE(...) __VA_ARGS__ ## _END
0016 
0017 // 
0018 // BOOST_HOF_PP_NARGS returns the number of args in __VA_ARGS__
0019 // 
0020 #define BOOST_HOF_PP_NARGS(...) \
0021          BOOST_HOF_PP_DETAIL_NARG((__VA_ARGS__,BOOST_HOF_PP_DETAIL_RSEQ_N()))
0022 
0023 #define BOOST_HOF_PP_DETAIL_NARG(args) \
0024         BOOST_HOF_PP_DETAIL_ARG_N args
0025 
0026 #define BOOST_HOF_PP_DETAIL_ARG_N( \
0027           _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
0028          _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
0029          _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
0030          _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
0031          _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
0032          _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
0033          _61,_62,_63,N,...) N
0034 #define BOOST_HOF_PP_DETAIL_RSEQ_N() \
0035          63,62,61,60,                   \
0036          59,58,57,56,55,54,53,52,51,50, \
0037          49,48,47,46,45,44,43,42,41,40, \
0038          39,38,37,36,35,34,33,32,31,30, \
0039          29,28,27,26,25,24,23,22,21,20, \
0040          19,18,17,16,15,14,13,12,11,10, \
0041          9,8,7,6,5,4,3,2,1,0 
0042 
0043 
0044 //
0045 // BOOST_HOF_PP_IS_PAREN is used to detect if the first token is a parenthesis.
0046 // It expands to 1 if it is, otherwise it expands to 0.
0047 //
0048 #define BOOST_HOF_PP_IS_PAREN(x) BOOST_HOF_PP_IS_PAREN_CHECK(BOOST_HOF_PP_IS_PAREN_PROBE x)
0049 #define BOOST_HOF_PP_IS_PAREN_CHECK(...) BOOST_HOF_PP_IS_PAREN_CHECK_N(__VA_ARGS__,0)
0050 #define BOOST_HOF_PP_IS_PAREN_PROBE(...) ~, 1,
0051 #ifndef _MSC_VER
0052 #define BOOST_HOF_PP_IS_PAREN_CHECK_N(x, n, ...) n
0053 #else
0054 // MSVC workarounds
0055 #define BOOST_HOF_PP_IS_PAREN_CHECK_RES(x) x
0056 #define BOOST_HOF_PP_IS_PAREN_CHECK_II(x, n, ...) n
0057 #define BOOST_HOF_PP_IS_PAREN_CHECK_I(x) BOOST_HOF_PP_IS_PAREN_CHECK_RES(BOOST_HOF_PP_IS_PAREN_CHECK_II x)
0058 #define BOOST_HOF_PP_IS_PAREN_CHECK_N(...) BOOST_HOF_PP_IS_PAREN_CHECK_I((__VA_ARGS__))
0059 #endif
0060 
0061 //
0062 // BOOST_HOF_PP_IS_1 is used to detect if the first token is a 1.
0063 // It expands to 1 if it is, otherwise it expands to 0.
0064 //
0065 #define BOOST_HOF_PP_IS_1(x) BOOST_HOF_PP_IS_PAREN(BOOST_HOF_PP_CAT(BOOST_HOF_PP_IS_1_PROBE_, x))
0066 #define BOOST_HOF_PP_IS_1_PROBE_1 ()
0067 
0068 #define BOOST_HOF_PP_ARGS_IS_SINGLE(...) BOOST_HOF_PP_IS_1(BOOST_HOF_PP_NARGS(__VA_ARGS__))
0069 
0070 #define BOOST_HOF_PP_EMPTY(...)
0071 #define BOOST_HOF_PP_DEFER(...) __VA_ARGS__ BOOST_HOF_PP_EMPTY()
0072 #define BOOST_HOF_PP_OBSTRUCT(...) __VA_ARGS__ BOOST_HOF_PP_DEFER(BOOST_HOF_PP_EMPTY)()
0073 #define BOOST_HOF_PP_EXPAND(...) __VA_ARGS__
0074 
0075 #define BOOST_HOF_PP_IIF(c) BOOST_HOF_PP_PRIMITIVE_CAT(BOOST_HOF_PP_IIF_, c)
0076 #define BOOST_HOF_PP_IIF_0(t, ...) __VA_ARGS__
0077 #define BOOST_HOF_PP_IIF_1(t, ...) t
0078 
0079 #define BOOST_HOF_PP_WALL(...) __VA_ARGS__
0080 
0081 #define BOOST_HOF_PP_RAIL_IIF(c) BOOST_HOF_PP_PRIMITIVE_CAT(BOOST_HOF_PP_RAIL_IIF_, c)
0082 #define BOOST_HOF_PP_RAIL_IIF_0(t, ...) __VA_ARGS__
0083 #define BOOST_HOF_PP_RAIL_IIF_1(t, ...) t
0084 
0085 #define BOOST_HOF_PP_RAIL(macro) \
0086     BOOST_HOF_PP_RAIL_IIF(BOOST_HOF_PP_IS_PAREN(BOOST_HOF_PP_WALL(())))( \
0087         BOOST_HOF_PP_RAIL_ID BOOST_HOF_PP_OBSTRUCT()()(macro), \
0088         macro BOOST_HOF_PP_OBSTRUCT() \
0089     )
0090 
0091 #define BOOST_HOF_PP_RAIL_ID() BOOST_HOF_PP_RAIL
0092 
0093 #endif