annotate DEPENDENCIES/generic/include/boost/local_function/aux_/macro/name.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1
Chris@16 2 // Copyright (C) 2009-2012 Lorenzo Caminiti
Chris@16 3 // Distributed under the Boost Software License, Version 1.0
Chris@16 4 // (see accompanying file LICENSE_1_0.txt or a copy at
Chris@16 5 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 // Home at http://www.boost.org/libs/local_function
Chris@16 7
Chris@16 8 #ifndef BOOST_LOCAL_FUNCTION_AUX_NAME_HPP_
Chris@16 9 #define BOOST_LOCAL_FUNCTION_AUX_NAME_HPP_
Chris@16 10
Chris@16 11 #include <boost/local_function/config.hpp>
Chris@16 12 #include <boost/local_function/aux_/macro/decl.hpp>
Chris@16 13 #include <boost/local_function/aux_/macro/code_/functor.hpp>
Chris@16 14 #include <boost/local_function/detail/preprocessor/keyword/recursive.hpp>
Chris@16 15 #include <boost/local_function/detail/preprocessor/keyword/inline.hpp>
Chris@16 16 #include <boost/local_function/aux_/function.hpp>
Chris@16 17 #include <boost/local_function/aux_/symbol.hpp>
Chris@16 18 #include <boost/preprocessor/control/iif.hpp>
Chris@16 19 #include <boost/preprocessor/control/expr_iif.hpp>
Chris@16 20 #include <boost/preprocessor/logical/bitor.hpp>
Chris@16 21 #include <boost/preprocessor/tuple/eat.hpp>
Chris@16 22
Chris@16 23 // PRIVATE //
Chris@16 24
Chris@16 25 #define BOOST_LOCAL_FUNCTION_AUX_NAME_LOCAL_TYPE_(local_function_name) \
Chris@16 26 BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (local_type)(local_function_name) )
Chris@16 27
Chris@16 28 #define BOOST_LOCAL_FUNCTION_AUX_NAME_INIT_RECURSION_FUNC_ \
Chris@16 29 BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (init_recursion) )
Chris@16 30
Chris@16 31 #define BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_FUNC_( \
Chris@16 32 is_recursive, local_function_name) \
Chris@16 33 BOOST_PP_IIF(is_recursive, \
Chris@16 34 local_function_name \
Chris@16 35 , \
Chris@16 36 BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (nonrecursive_local_function_name) ) \
Chris@16 37 )
Chris@16 38
Chris@16 39 #define BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \
Chris@16 40 local_function_name, is_recursive, \
Chris@16 41 local_functor_name, nonlocal_functor_name) \
Chris@16 42 /* FUNCTION macro expanded to: typedef class functor ## __LINE__ { ... */ \
Chris@16 43 BOOST_PP_EXPR_IIF(is_recursive, \
Chris@16 44 /* member var with function name for recursive calls; it cannot be */ \
Chris@16 45 /* `const` because it is init after construction (because */ \
Chris@16 46 /* constructor doesn't know local function name) */ \
Chris@16 47 /* run-time: even when optimizing, recursive calls cannot be */ \
Chris@16 48 /* optimized (i.e., they must be via the non-local functor) */ \
Chris@16 49 /* because this cannot be a mem ref because its name is not known */ \
Chris@16 50 /* by the constructor so it cannot be set by the mem init list */ \
Chris@16 51 private: \
Chris@16 52 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_TYPE \
Chris@16 53 BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_FUNC_(is_recursive, \
Chris@16 54 local_function_name); \
Chris@16 55 /* run-time: the `init_recursion()` function cannot be called */ \
Chris@16 56 /* by the constructor to allow for compiler optimization */ \
Chris@16 57 /* (inlining) so it must be public to be called (see below) */ \
Chris@16 58 public: \
Chris@16 59 inline void BOOST_LOCAL_FUNCTION_AUX_NAME_INIT_RECURSION_FUNC_( \
Chris@16 60 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_TYPE& functor) { \
Chris@16 61 local_function_name = functor; \
Chris@16 62 } \
Chris@16 63 ) \
Chris@16 64 } BOOST_LOCAL_FUNCTION_AUX_NAME_LOCAL_TYPE_(local_function_name); \
Chris@16 65 /* local functor can be passed as tparam only on C++11 (faster) */ \
Chris@16 66 BOOST_LOCAL_FUNCTION_AUX_NAME_LOCAL_TYPE_(local_function_name) \
Chris@16 67 local_functor_name(BOOST_LOCAL_FUNCTION_AUX_DECL_ARGS_VAR.value); \
Chris@16 68 /* non-local functor can always be passed as tparam (but slower) */ \
Chris@16 69 BOOST_PP_EXPR_IIF(typename01, typename) \
Chris@16 70 BOOST_LOCAL_FUNCTION_AUX_NAME_LOCAL_TYPE_(local_function_name):: \
Chris@16 71 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_TYPE \
Chris@16 72 nonlocal_functor_name; /* functor variable */ \
Chris@16 73 /* the order of the following 2 function calls cannot be changed */ \
Chris@16 74 /* because init_recursion uses the local_functor so the local_functor */ \
Chris@16 75 /* must be init first */ \
Chris@16 76 local_functor_name.BOOST_LOCAL_FUNCTION_AUX_FUNCTION_INIT_CALL_FUNC( \
Chris@16 77 &local_functor_name, nonlocal_functor_name); \
Chris@16 78 BOOST_PP_EXPR_IIF(is_recursive, \
Chris@16 79 /* init recursion causes MSVC to not optimize local function not */ \
Chris@16 80 /* even when local functor is used as template parameter so no */ \
Chris@16 81 /* recursion unless all inlining optimizations are specified off */ \
Chris@16 82 local_functor_name.BOOST_LOCAL_FUNCTION_AUX_NAME_INIT_RECURSION_FUNC_( \
Chris@16 83 nonlocal_functor_name); \
Chris@16 84 )
Chris@16 85
Chris@16 86 #define BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_(local_function_name) \
Chris@16 87 BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (local_function_name) )
Chris@16 88
Chris@16 89 // This can always be passed as a template parameters (on all compilers).
Chris@16 90 // However, it is slower because it cannot be inlined.
Chris@16 91 // Passed at tparam: Yes (on all C++). Inlineable: No. Recursive: No.
Chris@16 92 #define BOOST_LOCAL_FUNCTION_AUX_NAME_(typename01, local_function_name) \
Chris@16 93 BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \
Chris@16 94 local_function_name, \
Chris@16 95 /* local function is not recursive (because recursion and its */ \
Chris@16 96 /* initialization cannot be inlined even on C++11, */ \
Chris@16 97 /* so this allows optimization at least on C++11) */ \
Chris@16 98 0 /* not recursive */ , \
Chris@16 99 /* local functor */ \
Chris@16 100 BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_(local_function_name), \
Chris@16 101 /* local function declared as non-local functor -- but it can */ \
Chris@16 102 /* be inlined only by C++11 and it cannot be recursive */ \
Chris@16 103 local_function_name)
Chris@16 104
Chris@16 105 // This is faster on some compilers but not all (e.g., it is faster on GCC
Chris@16 106 // because its optimization inlines it but not on MSVC). However, it cannot be
Chris@16 107 // passed as a template parameter on non C++11 compilers.
Chris@16 108 // Passed at tparam: Only on C++11. Inlineable: Yes. Recursive: No.
Chris@16 109 #define BOOST_LOCAL_FUNCTION_AUX_NAME_INLINE_(typename01, local_function_name) \
Chris@16 110 BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \
Chris@16 111 local_function_name, \
Chris@16 112 /* inlined local function is never recursive (because recursion */ \
Chris@16 113 /* and its initialization cannot be inlined)*/ \
Chris@16 114 0 /* not recursive */ , \
Chris@16 115 /* inlined local function declared as local functor (maybe */ \
Chris@16 116 /* inlined even by non C++11 -- but it can be passed as */ \
Chris@16 117 /* template parameter only on C++11 */ \
Chris@16 118 local_function_name, \
Chris@16 119 /* non-local functor */ \
Chris@16 120 BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_(local_function_name))
Chris@16 121
Chris@16 122 // This is slower on all compilers (C++11 and non) because recursion and its
Chris@16 123 // initialization can never be inlined.
Chris@16 124 // Passed at tparam: Yes. Inlineable: No. Recursive: Yes.
Chris@16 125 #define BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_( \
Chris@16 126 typename01, local_function_name) \
Chris@16 127 BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \
Chris@16 128 local_function_name, \
Chris@16 129 /* recursive local function -- but it cannot be inlined */ \
Chris@16 130 1 /* recursive */ , \
Chris@16 131 /* local functor */ \
Chris@16 132 BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_(local_function_name), \
Chris@16 133 /* local function declared as non-local functor -- but it can */ \
Chris@16 134 /* be inlined only by C++11 */ \
Chris@16 135 local_function_name)
Chris@16 136
Chris@16 137 // Inlined local functions are specified by `..._NAME(inline name)`.
Chris@16 138 // They have more chances to be inlined for faster run-times by some compilers
Chris@16 139 // (for example by GCC but not by MSVC). C++11 compilers can always inline
Chris@16 140 // local functions even if they are not explicitly specified inline.
Chris@16 141 #define BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_INLINE_( \
Chris@16 142 typename01, qualified_name) \
Chris@16 143 BOOST_PP_IIF(BOOST_PP_BITOR( \
Chris@16 144 BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS, \
Chris@16 145 BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_INLINE_FRONT( \
Chris@16 146 qualified_name)), \
Chris@16 147 /* on C++11 always use inlining because compilers might optimize */ \
Chris@16 148 /* it to be faster and it can also be passed as tparam */ \
Chris@16 149 BOOST_LOCAL_FUNCTION_AUX_NAME_INLINE_ \
Chris@16 150 , \
Chris@16 151 /* on non C++11 don't use liniling unless explicitly specified by */ \
Chris@16 152 /* programmers `inline name` the inlined local function cannot be */ \
Chris@16 153 /* passed as tparam */ \
Chris@16 154 BOOST_LOCAL_FUNCTION_AUX_NAME_ \
Chris@16 155 )(typename01, BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT( \
Chris@16 156 qualified_name))
Chris@16 157
Chris@16 158 // Expand to 1 iff `recursive name` or `recursive inline name` or
Chris@16 159 // `inline recursive name`.
Chris@16 160 #define BOOST_LOCAL_FUNCTION_AUX_NAME_IS_RECURSIVE_(qualified_name) \
Chris@16 161 BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_RECURSIVE_FRONT( \
Chris@16 162 BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT( \
Chris@16 163 qualified_name \
Chris@16 164 ))
Chris@16 165
Chris@16 166 // Revmoes `recursive`, `inline recursive`, and `recursive inline` from front.
Chris@16 167 #define BOOST_LOCAL_FUNCTION_AUX_NAME_REMOVE_RECURSIVE_AND_INLINE_( \
Chris@16 168 qualified_name) \
Chris@16 169 BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_RECURSIVE_REMOVE_FRONT( \
Chris@16 170 BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT( \
Chris@16 171 BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_RECURSIVE_REMOVE_FRONT( \
Chris@16 172 qualified_name \
Chris@16 173 )))
Chris@16 174
Chris@16 175 #define BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_REMOVE_(qualified_name) \
Chris@16 176 BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_NAME_IS_RECURSIVE_(qualified_name), \
Chris@16 177 BOOST_LOCAL_FUNCTION_AUX_NAME_REMOVE_RECURSIVE_AND_INLINE_ \
Chris@16 178 , \
Chris@16 179 qualified_name /* might be `name` or `inline name` */ \
Chris@16 180 BOOST_PP_TUPLE_EAT(1) \
Chris@16 181 )(qualified_name)
Chris@16 182
Chris@16 183 // Recursive local function are specified by `..._NAME(recursive name)`.
Chris@16 184 // They can never be inlined for faster run-time (not even by C++11 compilers).
Chris@16 185 #define BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_RECURSIVE_( \
Chris@16 186 typename01, qualified_name) \
Chris@16 187 BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_NAME_IS_RECURSIVE_(qualified_name), \
Chris@16 188 /* recursion can never be inlined (not even on C++11) */ \
Chris@16 189 BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_ \
Chris@16 190 , \
Chris@16 191 BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_INLINE_ \
Chris@16 192 )(typename01, \
Chris@16 193 BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_REMOVE_(qualified_name))
Chris@16 194
Chris@16 195 // PUBLIC //
Chris@16 196
Chris@16 197 #define BOOST_LOCAL_FUNCTION_AUX_NAME(typename01, qualified_name) \
Chris@16 198 BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_RECURSIVE_(typename01, qualified_name)
Chris@16 199
Chris@16 200 #endif // #include guard
Chris@16 201