]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
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 | |
7 | ||
8 | #ifndef BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_HPP_ | |
9 | #define BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_HPP_ | |
10 | ||
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> | |
15 | ||
16 | // PRIVATE // | |
17 | ||
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) | |
23 | #else | |
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_( \ | |
27 | par) \ | |
28 | BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_EXPAND_I_ ## par | |
29 | #endif | |
30 | #define BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_FACILITY_REMOVE_EXPAND_I_(x) x | |
31 | ||
32 | // PUBLIC // | |
33 | ||
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), \ | |
41 | BOOST_PP_CAT \ | |
42 | , \ | |
43 | tokens BOOST_PP_TUPLE_EAT(2) \ | |
44 | )(removing_prefix, tokens) \ | |
45 | ) | |
46 | ||
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), \ | |
52 | BOOST_PP_CAT \ | |
53 | , \ | |
54 | tokens BOOST_PP_TUPLE_EAT(2) \ | |
55 | )(tokens, removing_postfix) | |
56 | ||
57 | #endif // #include guard | |
58 |