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_CONFIG_HPP_ 9 #define BOOST_LOCAL_FUNCTION_CONFIG_HPP_ 10 11 #ifndef DOXYGEN 12 13 #include <boost/config.hpp> 14 15 #ifndef BOOST_LOCAL_FUNCTION_CONFIG_FUNCTION_ARITY_MAX 16 # define BOOST_LOCAL_FUNCTION_CONFIG_FUNCTION_ARITY_MAX 5 17 #endif 18 19 #ifndef BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX 20 # define BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX 10 21 #endif 22 23 #ifndef BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS 24 # ifdef BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS 25 # define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS 0 26 # else 27 # define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS 1 28 # endif 29 #elif BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS // If true, force it to 1. 30 # undef BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS 31 # define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS 1 32 #endif 33 34 #else // DOXYGEN 35 36 /** @file 37 @brief Configuration macros allow to change the behaviour of this library at 38 compile-time. 39 */ 40 41 /** 42 @brief Maximum number of parameters supported by local functions. 43 44 If programmers leave this configuration macro undefined, its default 45 value is <c>5</c> (increasing this number might increase compilation time). 46 When defined by programmers, this macro must be a non-negative integer number. 47 48 @Note This macro specifies the maximum number of local function parameters 49 excluding bound variables (which are instead specified by 50 @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX}). 51 52 @See @RefSect{tutorial, Tutorial} section, 53 @RefSect{getting_started, Getting Started} section, 54 @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX}. 55 */ 56 #define BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX 57 58 /** 59 @brief Maximum number of bound variables supported by local functions. 60 61 If programmers leave this configuration macro undefined, its default 62 value is <c>10</c> (increasing this number might increase compilation time). 63 When defined by programmers, this macro must be a non-negative integer number. 64 65 @Note This macro specifies the maximum number of bound variables excluding 66 local function parameters (which are instead specified by 67 @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX}). 68 69 @See @RefSect{tutorial, Tutorial} section, 70 @RefSect{getting_started, Getting Started} section, 71 @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX}. 72 */ 73 #define BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX 74 75 /** 76 @brief Specify when local functions can be passed as template parameters 77 without introducing any run-time overhead. 78 79 If this macro is defined to <c>1</c>, this library will assume that the 80 compiler allows to pass local classes as template parameters: 81 @code 82 template<typename T> void f(void) {} 83 84 int main(void) { 85 struct local_class {}; 86 f<local_class>(); 87 return 0; 88 } 89 @endcode 90 This is the case for C++11 compilers and some C++03 compilers (e.g., MSVC), but 91 it is not the case in general for most C++03 compilers (including GCC). 92 This will allow the library to pass local functions as template parameters 93 without introducing any run-time overhead (specifically without preventing the 94 compiler from optimizing local function calls by inlining their assembly code). 95 96 If this macro is defined to <c>0</c> instead, this library will introduce 97 a run-time overhead associated to resolving a function pointer call in order to 98 still allow to pass the local functions as template parameters. 99 100 It is recommended to leave this macro undefined. 101 In this case, the library will automatically define this macro to <c>0</c> if 102 the Boost.Config macro <c>BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS</c> is 103 defined for the specific compiler, and to <c>1</c> otherwise. 104 105 @See @RefSect{getting_started, Getting Started} section, 106 @RefSect{advanced_topics, Advanced Topics} section, 107 @RefMacro{BOOST_LOCAL_FUNCTION_NAME}. 108 */ 109 #define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS 110 111 #endif // DOXYGEN 112 113 #endif // #include guard 114 115