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