From 633a77427671bdad47a6aca3e4fd7f87b57a5802 Mon Sep 17 00:00:00 2001 From: Lorenzo Caminiti Date: Wed, 4 Apr 2012 19:35:34 +0000 Subject: [PATCH] Compiling all ScopeExit and LocalFunction tests and examples on GCC with and without type-of emulation mode. Added LocalFunction configuration macro to force use or not use of locals as template parameters. [SVN r77765] --- example/expensive_copy_local_function.cpp | 3 + example/n2529_this.cpp | 5 + example/n2550_find_if.cpp | 3 + example/noncopyable_local_function.cpp | 3 + include/boost/local_function.hpp | 12 +- include/boost/local_function/aux_/config.hpp | 36 ------ .../boost/local_function/aux_/function.hpp | 19 ++-- .../local_function/aux_/macro/code_/end.hpp | 97 ----------------- .../aux_/macro/code_/functor.hpp | 12 +- .../local_function/aux_/macro/code_/name.hpp | 103 ------------------ .../boost/local_function/aux_/macro/name.hpp | 46 ++++---- include/boost/local_function/aux_/nobind.hpp | 4 +- include/boost/local_function/config.hpp | 30 ++++- test/add_template.cpp | 4 +- test/add_template_seq.cpp | 2 +- test/add_this.cpp | 5 + test/add_this_seq.cpp | 5 + test/add_typed.cpp | 9 +- test/add_typed_seq.cpp | 5 + test/factorial.cpp | 2 +- test/factorial_seq.cpp | 2 +- test/macro_commas.cpp | 2 + test/macro_commas_seq.cpp | 2 + test/operator.cpp | 5 +- test/operator_error.cpp | 3 + test/operator_error_seq.cpp | 3 + test/operator_seq.cpp | 3 + test/overload.cpp | 1 + test/overload_seq.cpp | 1 + test/return_derivative.cpp | 4 + test/return_derivative_seq.cpp | 4 + test/return_setget.cpp | 1 + test/return_setget_seq.cpp | 1 + test/return_this.cpp | 5 + test/return_this_seq.cpp | 5 + test/typeof_template.cpp | 2 +- test/typeof_template_seq.cpp | 2 +- 37 files changed, 164 insertions(+), 287 deletions(-) delete mode 100644 include/boost/local_function/aux_/config.hpp delete mode 100644 include/boost/local_function/aux_/macro/code_/end.hpp delete mode 100644 include/boost/local_function/aux_/macro/code_/name.hpp diff --git a/example/expensive_copy_local_function.cpp b/example/expensive_copy_local_function.cpp index 5dfde05..ed67fec 100644 --- a/example/expensive_copy_local_function.cpp +++ b/example/expensive_copy_local_function.cpp @@ -6,6 +6,8 @@ // Home at http://www.boost.org/libs/local_function #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include #include @@ -17,6 +19,7 @@ struct n { for (unsigned i = 0; i < 10000; ++i) std::cout << '.'; } }; +BOOST_TYPEOF_REGISTER_TYPE(n) // Register for `bind& x` below. int main(void) { n x(-1); diff --git a/example/n2529_this.cpp b/example/n2529_this.cpp index 741cf92..1a954ad 100644 --- a/example/n2529_this.cpp +++ b/example/n2529_this.cpp @@ -6,10 +6,15 @@ // Home at http://www.boost.org/libs/local_function #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include #include #include +struct v; +BOOST_TYPEOF_REGISTER_TYPE(v) // Register before `bind this_` below. + struct v { std::vector nums; diff --git a/example/n2550_find_if.cpp b/example/n2550_find_if.cpp index f3c2fc0..f372707 100644 --- a/example/n2550_find_if.cpp +++ b/example/n2550_find_if.cpp @@ -6,6 +6,8 @@ // Home at http://www.boost.org/libs/local_function #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include #include #include @@ -14,6 +16,7 @@ struct employee { int salary; explicit employee(const int& a_salary): salary(a_salary) {} }; +BOOST_TYPEOF_REGISTER_TYPE(employee) // Register for `NAME` below. int main(void) { std::vector employees; diff --git a/example/noncopyable_local_function.cpp b/example/noncopyable_local_function.cpp index 8a3e720..53bc580 100644 --- a/example/noncopyable_local_function.cpp +++ b/example/noncopyable_local_function.cpp @@ -7,6 +7,8 @@ #include #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include //[noncopyable_local_function @@ -14,6 +16,7 @@ struct n: boost::noncopyable { int i; n(int _i): i(_i) {} }; +BOOST_TYPEOF_REGISTER_TYPE(n) // Register for `bind& x` below. int main() { n x(-1); diff --git a/include/boost/local_function.hpp b/include/boost/local_function.hpp index f860872..178117f 100644 --- a/include/boost/local_function.hpp +++ b/include/boost/local_function.hpp @@ -46,7 +46,12 @@ #endif // VARIADIC #define BOOST_LOCAL_FUNCTION_NAME(qualified_function_name) \ - BOOST_LOCAL_FUNCTION_AUX_NAME(qualified_function_name) + BOOST_LOCAL_FUNCTION_AUX_NAME(0, /* not within template */ \ + qualified_function_name) + +#define BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_function_name) \ + BOOST_LOCAL_FUNCTION_AUX_NAME(1, /* within template */ \ + qualified_function_name) #define BOOST_LOCAL_FUNCTION_TYPEOF(bound_variable_name) \ BOOST_LOCAL_FUNCTION_AUX_TYPEOF_TYPE(bound_variable_name) @@ -297,6 +302,11 @@ Boost.Functional/OverloadedFunction and the */ #define BOOST_LOCAL_FUNCTION_NAME(qualified_function_name) +/** +In type-dependant context. +*/ +#define BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_function_name) + /** @brief This macro expands to the type of the specified bound variable. diff --git a/include/boost/local_function/aux_/config.hpp b/include/boost/local_function/aux_/config.hpp deleted file mode 100644 index a111ed6..0000000 --- a/include/boost/local_function/aux_/config.hpp +++ /dev/null @@ -1,36 +0,0 @@ - -// 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_AUX_CONFIG_HPP_ -#define BOOST_LOCAL_FUNCTION_AUX_CONFIG_HPP_ - -#include - -// PUBLIC // - -// NOTE: If local classes can be passes as template parameters (always true for -// C++11 and true for some C++03 compilers like MSVC and old GCC versions), -// this library uses it to optimize local function performances (which in this -// case are comparable to C++11 lambdas). -#ifdef BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS -# define BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01 0 -# if __GNUC__ -# warning "Boost.LocalFunction: Local class template parameters" -# elif BOOST_MSVC -# pragma message("Boost.LocalFunction: Local class template parameters") -# endif -#else -# define BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01 1 -# if __GNUC__ -# warning "Boost.LocalFunction: No local class template parameters" -# elif BOOST_MSVC -# pragma message("Boost.LocalFunction: No local class template parameters") -# endif -#endif - -#endif // #include guard - diff --git a/include/boost/local_function/aux_/function.hpp b/include/boost/local_function/aux_/function.hpp index 7f74abd..55c9ca1 100644 --- a/include/boost/local_function/aux_/function.hpp +++ b/include/boost/local_function/aux_/function.hpp @@ -10,7 +10,6 @@ # define BOOST_LOCAL_FUNCTION_AUX_FUNCTION_HPP_ # include -# include # include # include # include @@ -114,7 +113,7 @@ #define BOOST_LOCAL_FUNCTION_AUX_call_typedef(z, n, arity) \ typedef R (*BOOST_LOCAL_FUNCTION_AUX_call_ptr(z, n, ~))( \ object_ptr \ - BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01, \ + BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS, \ BOOST_PP_TUPLE_EAT(3) \ , \ BOOST_PP_REPEAT_ ## z \ @@ -153,7 +152,7 @@ return BOOST_LOCAL_FUNCTION_AUX_call_member(z, defaults_n, ~)( \ object_ \ BOOST_PP_IIF( \ - BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01,\ + BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS,\ BOOST_PP_TUPLE_EAT(3) \ , \ BOOST_PP_REPEAT_ ## z \ @@ -169,7 +168,7 @@ namespace boost { namespace local_function { namespace aux { template< typename F , size_t defaults -#if !BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01 +#if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, BOOST_LOCAL_FUNCTION_AUX_comma_bind_tparam, ~) #endif @@ -190,7 +189,7 @@ BOOST_TYPEOF_REGISTER_TEMPLATE(boost::local_function::aux::function, (typename) // For `F` tparam. (size_t) // For `defaults` tparam. // MSVC error if using #if instead of PP_IIF here. - BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01, + BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS, BOOST_PP_TUPLE_EAT(3) // Nothing. , BOOST_PP_REPEAT // For bind tparams. @@ -241,7 +240,7 @@ template< typename R BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_AUX_arity, BOOST_LOCAL_FUNCTION_AUX_comma_arg_tparam, ~) -#if !BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01 +#if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, BOOST_LOCAL_FUNCTION_AUX_comma_bind_tparam, ~) #endif @@ -252,7 +251,7 @@ class function< BOOST_LOCAL_FUNCTION_AUX_arg_type, ~) ) , BOOST_LOCAL_FUNCTION_AUX_defaults -#if !BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01 +#if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, BOOST_LOCAL_FUNCTION_AUX_comma_bind_type, ~) #endif @@ -288,7 +287,7 @@ public: // so used internal symbol. inline void BOOST_LOCAL_FUNCTION_AUX_FUNCTION_INIT_CALL_FUNC( object_ptr object -#if !BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01 +#if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, BOOST_LOCAL_FUNCTION_AUX_comma_bind_param_decl, ~) #endif @@ -296,7 +295,7 @@ public: BOOST_LOCAL_FUNCTION_AUX_comma_call_param_decl, ~) ) { object_ = object; -#if !BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01 +#if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, BOOST_LOCAL_FUNCTION_AUX_bind_member_init, ~) #endif @@ -314,7 +313,7 @@ public: private: object_ptr object_; -#if !BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01 +#if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS BOOST_PP_REPEAT(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, BOOST_LOCAL_FUNCTION_AUX_bind_member_decl, ~) #endif diff --git a/include/boost/local_function/aux_/macro/code_/end.hpp b/include/boost/local_function/aux_/macro/code_/end.hpp deleted file mode 100644 index 1ba8027..0000000 --- a/include/boost/local_function/aux_/macro/code_/end.hpp +++ /dev/null @@ -1,97 +0,0 @@ - -// 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_CLOSURE_AUX_CODE_END_HPP_ -#define BOOST_CLOSURE_AUX_CODE_END_HPP_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// PRIVATE // - -#define BOOST_CLOSURE_AUX_CODE_END_FUNCTOR_PTR_ \ - BOOST_CLOSURE_AUX_SYMBOL( (functor_ptr) ) - -#define BOOST_CLOSURE_AUX_CODE_END_FUNCTOR_(id, \ - local_function_name, local_functor_name, nonlocal_functor_name) \ - /* `PARAMS() { ... }` expandsion here -- still within functor class */ \ - /* class functor ## __LINE__ { ... */ \ - public: \ - /* LIMITATION: member var used to deduce functor type using TYPEOF */ \ - /* (so it must be public, ptr to always allow for default init); */ \ - /* unfortunately, this introduces a dependency with Boost.Typeof */ \ - /* that cannot be removed even when all binds and result types are */ \ - /* explicitly specified but this is necessary because the functor */ \ - /* type is known to the CLOSURE macro which must pass it to the */ \ - /* END macro that is defined on a different line */ \ - BOOST_CLOSURE_AUX_CODE_FUNCTOR_TYPE* \ - BOOST_CLOSURE_AUX_CODE_END_FUNCTOR_PTR_; \ - /* local functor can be passed as tparam only on C++11 (faster) */ \ - } local_functor_name(BOOST_CLOSURE_AUX_CLOSURE_ARGS_VAR.value); \ - /* non-local functor can always be passed as tparam (but slower) */ \ - BOOST_TYPEOF(*(local_functor_name.BOOST_CLOSURE_AUX_CODE_END_FUNCTOR_PTR_))\ - nonlocal_functor_name; \ - /* initialization */ \ - local_functor_name.BOOST_CLOSURE_AUX_FUNCTION_INIT_CALL_FUNC( \ - &local_functor_name, nonlocal_functor_name); - -#define BOOST_CLOSURE_AUX_CODE_END_FUNCTOR_VAR_(local_function_name) \ - BOOST_CLOSURE_AUX_SYMBOL( (local_function_name) ) - -// This can always be passed as a template parameters (on all compilers). -// However, it is slower because it cannot be inlined. -// Passed at tparam: Yes (on all C++). Inlineable: No. Recursive: No. -#define BOOST_CLOSURE_AUX_CODE_END_(local_function_name) \ - BOOST_CLOSURE_AUX_CODE_END_FUNCTOR_(__LINE__, local_function_name, \ - /* local functor */ \ - BOOST_CLOSURE_AUX_CODE_END_FUNCTOR_VAR_(local_function_name), \ - /* local function declared as non-local functor -- but it can */ \ - /* be inlined only by C++11 and it cannot be recursive */ \ - local_function_name) - -// This is faster on some compilers but not all (e.g., it is faster on GCC -// because its optimization inlines it but not on MSVC). However, it cannot be -// passed as a template parameter on non C++11 compilers. -// Passed at tparam: Only on C++11. Inlineable: Yes. Recursive: No. -#define BOOST_CLOSURE_AUX_CODE_END_INLINE_(local_function_name) \ - BOOST_CLOSURE_AUX_CODE_END_FUNCTOR_(__LINE__, local_function_name, \ - /* inlined local function declared as local functor (maybe */ \ - /* inlined even by non C++11 -- but it can be passed as */ \ - /* template parameter only on C++11 */ \ - local_function_name, \ - /* non-local functor */ \ - BOOST_CLOSURE_AUX_CODE_END_FUNCTOR_VAR_(local_function_name)) - -// PUBLIC // - -// Inlined local functions are specified by `..._NAME(inline name)`. -// They have more chances to be inlined for faster run-times by some compilers -// (for example by GCC but not by MSVC). C++11 compilers can always inline -// local functions even if they are not explicitly specified inline. -#define BOOST_CLOSURE_AUX_CODE_END(qualified_name) \ - BOOST_PP_IIF(BOOST_PP_BITOR( \ - BOOST_CLOSURE_AUX_CONFIG_LOCAL_TYPES_AS_TEMPLATE_PARAMS_01, \ - BOOST_CLOSURE_DETAIL_PP_KEYWORD_IS_INLINE_FRONT(qualified_name)), \ - /* on C++11 always use inlining because compilers might optimize */ \ - /* it to be faster and it can also be passed as tparam */ \ - BOOST_CLOSURE_AUX_CODE_END_INLINE_ \ - , \ - /* on non C++11 don't use liniling unless explicitly specified by */ \ - /* programmers `inline name` the inlined local function cannot be */ \ - /* passed as tparam */ \ - BOOST_CLOSURE_AUX_CODE_END_ \ - )(BOOST_CLOSURE_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT(qualified_name)) - -#endif // #include guard - diff --git a/include/boost/local_function/aux_/macro/code_/functor.hpp b/include/boost/local_function/aux_/macro/code_/functor.hpp index b99a69a..c9a0bdc 100644 --- a/include/boost/local_function/aux_/macro/code_/functor.hpp +++ b/include/boost/local_function/aux_/macro/code_/functor.hpp @@ -8,8 +8,8 @@ #ifndef BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_HPP_ #define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_HPP_ +#include #include -#include #include #include #include @@ -464,7 +464,7 @@ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_( \ inline static BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_TYPE(id) \ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_FUNC_(z, defaults_n, ~)( \ void* object \ - BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01, \ + BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS, \ BOOST_PP_TUPLE_EAT(6) \ , \ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_ \ @@ -486,7 +486,7 @@ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_( \ static_cast< \ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_CLASS_TYPE_(id)* \ >(object)-> \ - BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01,\ + BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS,\ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_OPERATOR_ \ , \ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_BODY_ \ @@ -703,8 +703,7 @@ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_( \ ::boost::local_function::aux::function< \ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_F_TYPE_ \ , default_count \ - BOOST_PP_IIF( \ - BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01, \ + BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS,\ BOOST_PP_TUPLE_EAT(6) \ , \ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_TYPES_\ @@ -767,8 +766,7 @@ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_STATIC_CALL_COMMA_BIND_PARAM_DECLS_( \ ) { \ functor.BOOST_LOCAL_FUNCTION_AUX_FUNCTION_INIT_CALL_FUNC( \ object \ - BOOST_PP_IIF( \ - BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01, \ + BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS,\ BOOST_PP_TUPLE_EAT(6) \ , \ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_STATIC_BINDS_ \ diff --git a/include/boost/local_function/aux_/macro/code_/name.hpp b/include/boost/local_function/aux_/macro/code_/name.hpp deleted file mode 100644 index f73bab6..0000000 --- a/include/boost/local_function/aux_/macro/code_/name.hpp +++ /dev/null @@ -1,103 +0,0 @@ - -// 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_AUX_CODE_NAME_HPP_ -#define BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_HPP_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// PRIVATE // - -#define BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_FUNCTOR_PTR_ \ - BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (functor_ptr) ) - -#define BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_FUNCTOR_(id, \ - local_function_name, local_functor_name, nonlocal_functor_name) \ - /* `PARAMS() { ... }` expandsion here -- still within functor class */ \ - /* class functor ## __LINE__ { ... */ \ - public: \ - /* LIMITATION: member var used to deduce functor type using TYPEOF */ \ - /* (so it must be public, ptr to always allow for default init); */ \ - /* unfortunately, this introduces a dependency with Boost.Typeof */ \ - /* that cannot be removed even when all binds and result types are */ \ - /* explicitly specified but this is necessary because the functor */ \ - /* type is known to the LOCAL_FUNCTION macro which must pass it to */ \ - /* the NAME macro that is defined on a different line */ \ - BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_TYPE* \ - BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_FUNCTOR_PTR_; \ - /* local functor can be passed as tparam only on C++11 (faster) */ \ - } local_functor_name( \ - BOOST_LOCAL_FUNCTION_AUX_DECL_ARGS_VAR.value); \ - /* non-local functor can always be passed as tparam (but slower) */ \ - BOOST_TYPEOF(*(local_functor_name. \ - BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_FUNCTOR_PTR_)) \ - nonlocal_functor_name; \ - /* initialization */ \ - local_functor_name.BOOST_LOCAL_FUNCTION_AUX_FUNCTION_INIT_CALL_FUNC( \ - &local_functor_name, nonlocal_functor_name); - -#define BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_FUNCTOR_VAR_(local_function_name) \ - BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (local_function_name) ) - -// This can always be passed as a template parameters (on all compilers). -// However, it is slower because it cannot be inlined. -// Passed at tparam: Yes (on all C++). Inlineable: No. Recursive: No. -#define BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_(local_function_name) \ - BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_FUNCTOR_(__LINE__, local_function_name, \ - /* local functor */ \ - BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_FUNCTOR_VAR_( \ - local_function_name), \ - /* local function declared as non-local functor -- but it can */ \ - /* be inlined only by C++11 and it cannot be recursive */ \ - local_function_name) - -// This is faster on some compilers but not all (e.g., it is faster on GCC -// because its optimization inlines it but not on MSVC). However, it cannot be -// passed as a template parameter on non C++11 compilers. -// Passed at tparam: Only on C++11. Inlineable: Yes. Recursive: No. -#define BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_INLINE_(local_function_name) \ - BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_FUNCTOR_(__LINE__, local_function_name, \ - /* inlined local function declared as local functor (maybe */ \ - /* inlined even by non C++11 -- but it can be passed as */ \ - /* template parameter only on C++11 */ \ - local_function_name, \ - /* non-local functor */ \ - BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_FUNCTOR_VAR_( \ - local_function_name)) - -// PUBLIC // - -// Inlined local functions are specified by `..._NAME(inline name)`. -// They have more chances to be inlined for faster run-times by some compilers -// (for example by GCC but not by MSVC). C++11 compilers can always inline -// local functions even if they are not explicitly specified inline. -#define BOOST_LOCAL_FUNCTION_AUX_CODE_NAME(qualified_name) \ - BOOST_PP_IIF(BOOST_PP_BITOR( \ - BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01, \ - BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_INLINE_FRONT( \ - qualified_name)), \ - /* on C++11 always use inlining because compilers might optimize */ \ - /* it to be faster and it can also be passed as tparam */ \ - BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_INLINE_ \ - , \ - /* on non C++11 don't use liniling unless explicitly specified by */ \ - /* programmers `inline name` the inlined local function cannot be */ \ - /* passed as tparam */ \ - BOOST_LOCAL_FUNCTION_AUX_CODE_NAME_ \ - )(BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT( \ - qualified_name)) - -#endif // #include guard - diff --git a/include/boost/local_function/aux_/macro/name.hpp b/include/boost/local_function/aux_/macro/name.hpp index c74aa0a..749cf9d 100644 --- a/include/boost/local_function/aux_/macro/name.hpp +++ b/include/boost/local_function/aux_/macro/name.hpp @@ -8,13 +8,13 @@ #ifndef BOOST_LOCAL_FUNCTION_AUX_NAME_HPP_ #define BOOST_LOCAL_FUNCTION_AUX_NAME_HPP_ +#include #include #include #include #include #include #include -#include #include #include #include @@ -34,7 +34,7 @@ BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (nonrecursive_local_function_name) ) \ ) -#define BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(id, \ +#define BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \ local_function_name, is_recursive, \ local_functor_name, nonlocal_functor_name) \ /* `PARAMS() { ... }` expandsion here -- still within functor class */ \ @@ -64,10 +64,14 @@ /* local functor can be passed as tparam only on C++11 (faster) */ \ } local_functor_name(BOOST_LOCAL_FUNCTION_AUX_DECL_ARGS_VAR.value); \ /* non-local functor can always be passed as tparam (but slower) */ \ - BOOST_TYPEOF(local_functor_name. \ - BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_FUNC_(is_recursive, \ - local_function_name)) \ - nonlocal_functor_name; \ + BOOST_PP_IIF(typename01, \ + BOOST_TYPEOF_TPL \ + , \ + BOOST_TYPEOF \ + )(local_functor_name.BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_FUNC_( \ + is_recursive, local_function_name)) \ + nonlocal_functor_name /* functor variable */ \ + ; \ /* the order of the following 2 function calls cannot be changed */ \ /* because init_recursion uses the local_functor so the local_functor */ \ /* must be init first */ \ @@ -87,8 +91,8 @@ // This can always be passed as a template parameters (on all compilers). // However, it is slower because it cannot be inlined. // Passed at tparam: Yes (on all C++). Inlineable: No. Recursive: No. -#define BOOST_LOCAL_FUNCTION_AUX_NAME_(local_function_name) \ - BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(__LINE__, \ +#define BOOST_LOCAL_FUNCTION_AUX_NAME_(typename01, local_function_name) \ + BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \ local_function_name, \ /* local function is not recursive (because recursion and its */ \ /* initialization cannot be inlined even on C++11, */ \ @@ -104,8 +108,8 @@ // because its optimization inlines it but not on MSVC). However, it cannot be // passed as a template parameter on non C++11 compilers. // Passed at tparam: Only on C++11. Inlineable: Yes. Recursive: No. -#define BOOST_LOCAL_FUNCTION_AUX_NAME_INLINE_(local_function_name) \ - BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(__LINE__, \ +#define BOOST_LOCAL_FUNCTION_AUX_NAME_INLINE_(typename01, local_function_name) \ + BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \ local_function_name, \ /* inlined local function is never recursive (because recursion */ \ /* and its initialization cannot be inlined)*/ \ @@ -120,8 +124,9 @@ // This is slower on all compilers (C++11 and non) because recursion and its // initialization can never be inlined. // Passed at tparam: Yes. Inlineable: No. Recursive: Yes. -#define BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_(local_function_name) \ - BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(__LINE__, \ +#define BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_( \ + typename01, local_function_name) \ + BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \ local_function_name, \ /* recursive local function -- but it cannot be inlined */ \ 1 /* recursive */ , \ @@ -135,9 +140,10 @@ // They have more chances to be inlined for faster run-times by some compilers // (for example by GCC but not by MSVC). C++11 compilers can always inline // local functions even if they are not explicitly specified inline. -#define BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_INLINE_(qualified_name) \ +#define BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_INLINE_( \ + typename01, qualified_name) \ BOOST_PP_IIF(BOOST_PP_BITOR( \ - BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01, \ + BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS, \ BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_INLINE_FRONT( \ qualified_name)), \ /* on C++11 always use inlining because compilers might optimize */ \ @@ -148,7 +154,7 @@ /* programmers `inline name` the inlined local function cannot be */ \ /* passed as tparam */ \ BOOST_LOCAL_FUNCTION_AUX_NAME_ \ - )(BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT( \ + )(typename01, BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT( \ qualified_name)) // Expand to 1 iff `recursive name` or `recursive inline name` or @@ -178,18 +184,20 @@ // Recursive local function are specified by `..._NAME(recursive name)`. // They can never be inlined for faster run-time (not even by C++11 compilers). -#define BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_RECURSIVE_(qualified_name) \ +#define BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_RECURSIVE_( \ + typename01, qualified_name) \ BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_NAME_IS_RECURSIVE_(qualified_name), \ /* recursion can never be inlined (not even on C++11) */ \ BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_ \ , \ BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_INLINE_ \ - )(BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_REMOVE_(qualified_name)) + )(typename01, \ + BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_REMOVE_(qualified_name)) // PUBLIC // -#define BOOST_LOCAL_FUNCTION_AUX_NAME(qualified_name) \ - BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_RECURSIVE_(qualified_name) +#define BOOST_LOCAL_FUNCTION_AUX_NAME(typename01, qualified_name) \ + BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_RECURSIVE_(typename01, qualified_name) #endif // #include guard diff --git a/include/boost/local_function/aux_/nobind.hpp b/include/boost/local_function/aux_/nobind.hpp index f2af5eb..73afc6f 100644 --- a/include/boost/local_function/aux_/nobind.hpp +++ b/include/boost/local_function/aux_/nobind.hpp @@ -8,11 +8,11 @@ #ifndef BOOST_LOCAL_FUNCTION_AUX_NOBIND_HPP_ #define BOOST_LOCAL_FUNCTION_AUX_NOBIND_HPP_ -#include +#include // NOTE: The current implementation needs no-bind placeholders only when // local types cannot be passed as template parameters. -#if !BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01 +#if !BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS namespace boost { namespace local_function { namespace aux { diff --git a/include/boost/local_function/config.hpp b/include/boost/local_function/config.hpp index 7285695..942174c 100644 --- a/include/boost/local_function/config.hpp +++ b/include/boost/local_function/config.hpp @@ -10,12 +10,30 @@ #ifndef DOXYGEN +#include + #ifndef BOOST_LOCAL_FUNCTION_CONFIG_FUNCTION_ARITY_MAX -#define BOOST_LOCAL_FUNCTION_CONFIG_FUNCTION_ARITY_MAX 5 +# 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 +# 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 +#if BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS +# warning "locals as tparams" +#else +# warning "no locals as tparams" #endif #else // DOXYGEN @@ -57,6 +75,14 @@ section, @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX}. */ #define BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX +/** +Control performance optimizations. +Automatically set using Boost.Config BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS +if not defined by user. +0 - no optimization, 1 - optimization. +*/ +#define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS + #endif // DOXYGEN #endif // #include guard diff --git a/test/add_template.cpp b/test/add_template.cpp index 3f9425c..5ce77cf 100644 --- a/test/add_template.cpp +++ b/test/add_template.cpp @@ -19,10 +19,10 @@ template T total(const T& x, const T& y, const T& z) { T sum = T(), factor = 10; - // Using the `..._TPL` macro. + // Must use the `..._TPL` macros within templates. T BOOST_LOCAL_FUNCTION_TPL(const bind factor, bind& sum, T num) { return sum += factor * num; - } BOOST_LOCAL_FUNCTION_NAME(add) + } BOOST_LOCAL_FUNCTION_NAME_TPL(add) add(x); T nums[2]; nums[0] = y; nums[1] = z; diff --git a/test/add_template_seq.cpp b/test/add_template_seq.cpp index 8e89347..3c0ea71 100644 --- a/test/add_template_seq.cpp +++ b/test/add_template_seq.cpp @@ -15,7 +15,7 @@ T total(const T& x, const T& y, const T& z) { T BOOST_LOCAL_FUNCTION_TPL( (const bind factor) (bind& sum) (T num) ) { return sum += factor * num; - } BOOST_LOCAL_FUNCTION_NAME(add) + } BOOST_LOCAL_FUNCTION_NAME_TPL(add) add(x); T nums[2]; nums[0] = y; nums[1] = z; diff --git a/test/add_this.cpp b/test/add_this.cpp index 53dee3e..11071d2 100644 --- a/test/add_this.cpp +++ b/test/add_this.cpp @@ -11,10 +11,15 @@ #else #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include #include #include +struct adder; +BOOST_TYPEOF_REGISTER_TYPE(adder) // Register before `bind this_` below. + //[add_this struct adder { adder() : sum_(0) {} diff --git a/test/add_this_seq.cpp b/test/add_this_seq.cpp index 633d1b9..9957122 100644 --- a/test/add_this_seq.cpp +++ b/test/add_this_seq.cpp @@ -6,10 +6,15 @@ // Home at http://www.boost.org/libs/local_function #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include #include #include +struct adder; +BOOST_TYPEOF_REGISTER_TYPE(adder) // Register before `bind this_` below. + struct adder { adder() : sum_(0) {} diff --git a/test/add_typed.cpp b/test/add_typed.cpp index 9172315..f0cb641 100644 --- a/test/add_typed.cpp +++ b/test/add_typed.cpp @@ -11,20 +11,25 @@ #else #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include #include #include //[add_typed +struct adder; +BOOST_TYPEOF_REGISTER_TYPE(adder) // Unfortunately needed for `..._NAME` below. + struct adder { adder() : sum_(0) {} int sum(const std::vector& nums, const int& factor = 10) { - // Explicitly specify bound variable and result types. + // Explicitly specify bound variable and result types... BOOST_LOCAL_FUNCTION(const bind(const int&) factor, bind(adder*) this_, int num, return int) { return this_->sum_ += factor * num; - } BOOST_LOCAL_FUNCTION_NAME(add) + } BOOST_LOCAL_FUNCTION_NAME(add) // ... but this still uses type-of. std::for_each(nums.begin(), nums.end(), add); return sum_; diff --git a/test/add_typed_seq.cpp b/test/add_typed_seq.cpp index 6e9e370..46aee3d 100644 --- a/test/add_typed_seq.cpp +++ b/test/add_typed_seq.cpp @@ -6,10 +6,15 @@ // Home at http://www.boost.org/libs/local_function #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include #include #include +struct adder; +BOOST_TYPEOF_REGISTER_TYPE(adder) // Needed for `NAME` below. + struct adder { adder() : sum_(0) {} diff --git a/test/factorial.cpp b/test/factorial.cpp index 2c32e19..07d98f3 100644 --- a/test/factorial.cpp +++ b/test/factorial.cpp @@ -18,7 +18,7 @@ #include struct calculator; -BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before bind `this_` below. +BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before `bind this_` below. //[factorial struct calculator { diff --git a/test/factorial_seq.cpp b/test/factorial_seq.cpp index 70dba02..e7c242c 100644 --- a/test/factorial_seq.cpp +++ b/test/factorial_seq.cpp @@ -13,7 +13,7 @@ #include struct calculator; -BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before bind `this_` below. +BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before `bind this_` below. struct calculator { std::vector results; diff --git a/test/macro_commas.cpp b/test/macro_commas.cpp index 787fd27..d8ee0ed 100644 --- a/test/macro_commas.cpp +++ b/test/macro_commas.cpp @@ -12,6 +12,8 @@ #include #include +#include // Type-of registrations +#include // needed for `NAME` macro. #include #include diff --git a/test/macro_commas_seq.cpp b/test/macro_commas_seq.cpp index e8fbb0a..888b396 100644 --- a/test/macro_commas_seq.cpp +++ b/test/macro_commas_seq.cpp @@ -7,6 +7,8 @@ #include #include +#include // Type-of registrations +#include // needed for `NAME` macro. #include #include #include diff --git a/test/operator.cpp b/test/operator.cpp index 86079f4..e5cdd96 100644 --- a/test/operator.cpp +++ b/test/operator.cpp @@ -11,6 +11,8 @@ #else #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include //[operator @@ -18,11 +20,12 @@ struct point { int x; int y; }; +BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below. int main(void) { bool BOOST_LOCAL_FUNCTION(const point& p, const point& q) { return p.x == q.x && p.y == q.y; - } BOOST_LOCAL_FUNCTION_NAME(equal) // OK: not using `operator...`. + } BOOST_LOCAL_FUNCTION_NAME(equal) // OK: not using `operator==`. point a; a.x = 1; a.y = 2; point b = a; diff --git a/test/operator_error.cpp b/test/operator_error.cpp index d0101c3..0316b2d 100644 --- a/test/operator_error.cpp +++ b/test/operator_error.cpp @@ -11,6 +11,8 @@ #else #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include //[operator_error @@ -18,6 +20,7 @@ struct point { int x; int y; }; +BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below. int main(void) { bool BOOST_LOCAL_FUNCTION(const point& p, const point& q) { diff --git a/test/operator_error_seq.cpp b/test/operator_error_seq.cpp index 5da791c..08c21f2 100644 --- a/test/operator_error_seq.cpp +++ b/test/operator_error_seq.cpp @@ -6,12 +6,15 @@ // Home at http://www.boost.org/libs/local_function #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include struct point { int x; int y; }; +BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below. int main(void) { bool BOOST_LOCAL_FUNCTION( (const point& p) (const point& q) ) { diff --git a/test/operator_seq.cpp b/test/operator_seq.cpp index 029390d..d4f70f4 100644 --- a/test/operator_seq.cpp +++ b/test/operator_seq.cpp @@ -6,12 +6,15 @@ // Home at http://www.boost.org/libs/local_function #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include struct point { int x; int y; }; +BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below. int main(void) { bool BOOST_LOCAL_FUNCTION( (const point& p) (const point& q) ) { diff --git a/test/overload.cpp b/test/overload.cpp index 8ed70b3..daceed3 100644 --- a/test/overload.cpp +++ b/test/overload.cpp @@ -12,6 +12,7 @@ #include #include // For overloading. +#include #include #include #include diff --git a/test/overload_seq.cpp b/test/overload_seq.cpp index b31c5d1..789b328 100644 --- a/test/overload_seq.cpp +++ b/test/overload_seq.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/test/return_derivative.cpp b/test/return_derivative.cpp index c80ac73..5bd05dc 100644 --- a/test/return_derivative.cpp +++ b/test/return_derivative.cpp @@ -12,8 +12,12 @@ #include #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include +BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function, 1) + boost::function derivative(boost::function& f, int dx) { int BOOST_LOCAL_FUNCTION(bind& f, const bind dx, int x) { return (f(x + dx) - f(x)) / dx; diff --git a/test/return_derivative_seq.cpp b/test/return_derivative_seq.cpp index 6f2ea4d..b32ba37 100644 --- a/test/return_derivative_seq.cpp +++ b/test/return_derivative_seq.cpp @@ -7,8 +7,12 @@ #include #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include +BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function, 1) + boost::function derivative(boost::function& f, int dx) { int BOOST_LOCAL_FUNCTION( (bind& f) (const bind dx) (int x) ) { return (f(x + dx) - f(x)) / dx; diff --git a/test/return_setget.cpp b/test/return_setget.cpp index 0d07350..37cc84a 100644 --- a/test/return_setget.cpp +++ b/test/return_setget.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include diff --git a/test/return_setget_seq.cpp b/test/return_setget_seq.cpp index 42c1246..33b1c35 100644 --- a/test/return_setget_seq.cpp +++ b/test/return_setget_seq.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include diff --git a/test/return_this.cpp b/test/return_this.cpp index 4669230..9bbc8bc 100644 --- a/test/return_this.cpp +++ b/test/return_this.cpp @@ -12,8 +12,13 @@ #include #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include +struct number; +BOOST_TYPEOF_REGISTER_TYPE(number) // Register before `bind this_` below. + struct number { number(int value) : value_(value) {} diff --git a/test/return_this_seq.cpp b/test/return_this_seq.cpp index be7870f..551d3e1 100644 --- a/test/return_this_seq.cpp +++ b/test/return_this_seq.cpp @@ -7,8 +7,13 @@ #include #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include +struct number; +BOOST_TYPEOF_REGISTER_TYPE(number) // Register before `bind this_` below. + struct number { number(int value) : value_(value) {} diff --git a/test/typeof_template.cpp b/test/typeof_template.cpp index f6a8c43..e514c98 100644 --- a/test/typeof_template.cpp +++ b/test/typeof_template.cpp @@ -27,7 +27,7 @@ T calculate(const T& factor) { BOOST_CONCEPT_ASSERT((Addable::type>)); sum += factor * num; - } BOOST_LOCAL_FUNCTION_NAME(add) + } BOOST_LOCAL_FUNCTION_NAME_TPL(add) add(6); return sum; diff --git a/test/typeof_template_seq.cpp b/test/typeof_template_seq.cpp index 9aca5a5..60028e9 100644 --- a/test/typeof_template_seq.cpp +++ b/test/typeof_template_seq.cpp @@ -20,7 +20,7 @@ T calculate(const T& factor) { BOOST_CONCEPT_ASSERT((Addable::type>)); sum += factor * num; - } BOOST_LOCAL_FUNCTION_NAME(add) + } BOOST_LOCAL_FUNCTION_NAME_TPL(add) add(6); return sum;