Chris@16: Chris@16: // Copyright (C) 2009-2012 Lorenzo Caminiti Chris@16: // Distributed under the Boost Software License, Version 1.0 Chris@16: // (see accompanying file LICENSE_1_0.txt or a copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Home at http://www.boost.org/libs/local_function Chris@16: Chris@16: #ifndef BOOST_LOCAL_FUNCTION_CONFIG_HPP_ Chris@16: #define BOOST_LOCAL_FUNCTION_CONFIG_HPP_ Chris@16: Chris@16: #ifndef DOXYGEN Chris@16: Chris@16: #include Chris@16: Chris@16: #ifndef BOOST_LOCAL_FUNCTION_CONFIG_FUNCTION_ARITY_MAX Chris@16: # define BOOST_LOCAL_FUNCTION_CONFIG_FUNCTION_ARITY_MAX 5 Chris@16: #endif Chris@16: Chris@16: #ifndef BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX Chris@16: # define BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX 10 Chris@16: #endif Chris@16: Chris@16: #ifndef BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS Chris@16: # ifdef BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS Chris@16: # define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS 0 Chris@16: # else Chris@16: # define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS 1 Chris@16: # endif Chris@16: #elif BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS // If true, force it to 1. Chris@16: # undef BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS Chris@16: # define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS 1 Chris@16: #endif Chris@16: Chris@16: #else // DOXYGEN Chris@16: Chris@16: /** @file Chris@16: @brief Configuration macros allow to change the behaviour of this library at Chris@16: compile-time. Chris@16: */ Chris@16: Chris@16: /** Chris@16: @brief Maximum number of parameters supported by local functions. Chris@16: Chris@16: If programmers leave this configuration macro undefined, its default Chris@16: value is 5 (increasing this number might increase compilation time). Chris@16: When defined by programmers, this macro must be a non-negative integer number. Chris@16: Chris@16: @Note This macro specifies the maximum number of local function parameters Chris@16: excluding bound variables (which are instead specified by Chris@16: @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX}). Chris@16: Chris@16: @See @RefSect{tutorial, Tutorial} section, Chris@16: @RefSect{getting_started, Getting Started} section, Chris@16: @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX}. Chris@16: */ Chris@16: #define BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX Chris@16: Chris@16: /** Chris@16: @brief Maximum number of bound variables supported by local functions. Chris@16: Chris@16: If programmers leave this configuration macro undefined, its default Chris@16: value is 10 (increasing this number might increase compilation time). Chris@16: When defined by programmers, this macro must be a non-negative integer number. Chris@16: Chris@16: @Note This macro specifies the maximum number of bound variables excluding Chris@16: local function parameters (which are instead specified by Chris@16: @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX}). Chris@16: Chris@16: @See @RefSect{tutorial, Tutorial} section, Chris@16: @RefSect{getting_started, Getting Started} section, Chris@16: @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX}. Chris@16: */ Chris@16: #define BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX Chris@16: Chris@16: /** Chris@16: @brief Specify when local functions can be passed as template parameters Chris@16: without introducing any run-time overhead. Chris@16: Chris@16: If this macro is defined to 1, this library will assume that the Chris@16: compiler allows to pass local classes as template parameters: Chris@16: @code Chris@16: template void f(void) {} Chris@16: Chris@16: int main(void) { Chris@16: struct local_class {}; Chris@16: f(); Chris@16: return 0; Chris@16: } Chris@16: @endcode Chris@16: This is the case for C++11 compilers and some C++03 compilers (e.g., MSVC), but Chris@16: it is not the case in general for most C++03 compilers (including GCC). Chris@16: This will allow the library to pass local functions as template parameters Chris@16: without introducing any run-time overhead (specifically without preventing the Chris@16: compiler from optimizing local function calls by inlining their assembly code). Chris@16: Chris@16: If this macro is defined to 0 instead, this library will introduce Chris@16: a run-time overhead associated to resolving a function pointer call in order to Chris@16: still allow to pass the local functions as template parameters. Chris@16: Chris@16: It is recommended to leave this macro undefined. Chris@16: In this case, the library will automatically define this macro to 0 if Chris@16: the Boost.Config macro BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS is Chris@16: defined for the specific compiler, and to 1 otherwise. Chris@16: Chris@16: @See @RefSect{getting_started, Getting Started} section, Chris@16: @RefSect{advanced_topics, Advanced Topics} section, Chris@16: @RefMacro{BOOST_LOCAL_FUNCTION_NAME}. Chris@16: */ Chris@16: #define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS Chris@16: Chris@16: #endif // DOXYGEN Chris@16: Chris@16: #endif // #include guard Chris@16: