config.hpp 4.0 KB

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