diff --git a/include/boost/local_function/aux_/config.hpp b/include/boost/local_function/aux_/config.hpp index e14adbe..a111ed6 100644 --- a/include/boost/local_function/aux_/config.hpp +++ b/include/boost/local_function/aux_/config.hpp @@ -18,8 +18,18 @@ // 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 580c30a..7f74abd 100644 --- a/include/boost/local_function/aux_/function.hpp +++ b/include/boost/local_function/aux_/function.hpp @@ -35,6 +35,9 @@ #define BOOST_LOCAL_FUNCTION_AUX_FUNCTION_INIT_CALL_FUNC \ BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (init_call) ) +#define BOOST_LOCAL_FUNCTION_AUX_typename_seq(z, n, unused) \ + (typename) + #define BOOST_LOCAL_FUNCTION_AUX_arg_type(z, arg_n, unused) \ BOOST_PP_CAT(A, arg_n) @@ -184,15 +187,18 @@ class function {}; // Empty template, only use its specializations. // Register type for type-of emu (NAME use TYPEOF to deduce this fctor type). #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() BOOST_TYPEOF_REGISTER_TEMPLATE(boost::local_function::aux::function, - BOOST_PP_ADD(2, // F and defaults tparams. - BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_CONFIG_LOCALS_AS_TPARAMS_01, - 0 // No additional tparam. - , - BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX // Bind tparams. - ) - ) + (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_TUPLE_EAT(3) // Nothing. + , + BOOST_PP_REPEAT // For bind tparams. + )(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, + BOOST_LOCAL_FUNCTION_AUX_typename_seq, ~) ) +#undef BOOST_LOCAL_FUNCTION_AUX_typename_seq #undef BOOST_LOCAL_FUNCTION_AUX_arg_type #undef BOOST_LOCAL_FUNCTION_AUX_arg_typedef #undef BOOST_LOCAL_FUNCTION_AUX_comma_arg_tparam diff --git a/test/all_decl.cpp b/test/all_decl.cpp index cda2292..0366aaa 100644 --- a/test/all_decl.cpp +++ b/test/all_decl.cpp @@ -11,6 +11,11 @@ #else #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + +struct s; +BOOST_TYPEOF_REGISTER_TYPE(s) // Register before binding `this_` below. // Compile all local function declaration combinations. struct s { diff --git a/test/all_decl_seq.cpp b/test/all_decl_seq.cpp index 2001e34..95fb75e 100644 --- a/test/all_decl_seq.cpp +++ b/test/all_decl_seq.cpp @@ -6,6 +6,11 @@ // Home at http://www.boost.org/libs/local_function #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + +struct s; +BOOST_TYPEOF_REGISTER_TYPE(s); // Register before bind `this_` below. // Compile all local function declaration combinations. struct s { diff --git a/test/factorial.cpp b/test/factorial.cpp index 71fb53b..2c32e19 100644 --- a/test/factorial.cpp +++ b/test/factorial.cpp @@ -11,10 +11,15 @@ #else #include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() #include #include #include +struct calculator; +BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before bind `this_` below. + //[factorial struct calculator { std::vector results; diff --git a/test/factorial_seq.cpp b/test/factorial_seq.cpp index f4c39be..70dba02 100644 --- a/test/factorial_seq.cpp +++ b/test/factorial_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 calculator; +BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before bind `this_` below. + struct calculator { std::vector results;