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_CONFIG_HPP_
9 #define BOOST_LOCAL_FUNCTION_CONFIG_HPP_
13 #include <boost/config.hpp>
15 #ifndef BOOST_LOCAL_FUNCTION_CONFIG_FUNCTION_ARITY_MAX
16 # define BOOST_LOCAL_FUNCTION_CONFIG_FUNCTION_ARITY_MAX 5
19 #ifndef BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX
20 # define BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX 10
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
27 # define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS 1
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
37 @brief Configuration macros allow to change the behaviour of this library at
42 @brief Maximum number of parameters supported by local functions.
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.
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}).
52 @See @RefSect{tutorial, Tutorial} section,
53 @RefSect{getting_started, Getting Started} section,
54 @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX}.
56 #define BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX
59 @brief Maximum number of bound variables supported by local functions.
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.
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}).
69 @See @RefSect{tutorial, Tutorial} section,
70 @RefSect{getting_started, Getting Started} section,
71 @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX}.
73 #define BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX
76 @brief Specify when local functions can be passed as template parameters
77 without introducing any run-time overhead.
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:
82 template<typename T> void f(void) {}
85 struct local_class {};
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).
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.
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.
105 @See @RefSect{getting_started, Getting Started} section,
106 @RefSect{advanced_topics, Advanced Topics} section,
107 @RefMacro{BOOST_LOCAL_FUNCTION_NAME}.
109 #define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS
113 #endif // #include guard