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