2 // Copyright (C) 2009-2012 Lorenzo Caminiti
3 // Distributed under the Boost Software License, Version 1.0
4 // (see accompanying file LICENSE_1_0.txt or a copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 // Home at http://www.boost.org/libs/local_function
8 #ifndef BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_HPP_
9 #define BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_HPP_
11 #include <boost/preprocessor/control/iif.hpp>
12 #include <boost/preprocessor/tuple/eat.hpp>
13 #include <boost/preprocessor/config/config.hpp>
14 #include <boost/preprocessor/cat.hpp>
18 // From PP_EXPAND (my own reentrant version).
19 #if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() && \
20 ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC()
21 # define BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_EXPAND_(x) \
22 BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_EXPAND_I_(x)
24 # define BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_EXPAND_(x) \
25 BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_EXPAND_OO_((x))
26 # define BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_EXPAND_OO_( \
28 BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_EXPAND_I_ ## par
30 #define BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_EXPAND_I_(x) x
34 // `is_front_macro(tokens)` is 1 if `tokens` start with keyword to remove.
35 // `removing_prefix ## <keyword-to-remove>` must expand to nothing, else 0.
36 #define BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT( \
37 tokens, is_front_macro, removing_prefix) \
38 /* without EXPAND doesn't expand on MSVC */ \
39 BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_EXPAND_( \
40 BOOST_PP_IIF(is_front_macro(tokens), \
43 tokens BOOST_PP_TUPLE_EAT(2) \
44 )(removing_prefix, tokens) \
47 // `is_back_macro(tokens)` is 1 iff `tokens` end with keyword to remove.
48 // `<keyword-to-remove> ## removing_postfix` must expand to nothing, else 0.
49 #define BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_BACK( \
50 tokens, is_back_macro, removing_prefix) \
51 BOOST_PP_IIF(is_back_macro(tokens), \
54 tokens BOOST_PP_TUPLE_EAT(2) \
55 )(tokens, removing_postfix)
57 #endif // #include guard