Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77755 - in trunk: boost/local_function/aux_ libs/local_function/test
From: lorcaminiti_at_[hidden]
Date: 2012-04-04 11:35:32


Author: lcaminiti
Date: 2012-04-04 11:35:30 EDT (Wed, 04 Apr 2012)
New Revision: 77755
URL: http://svn.boost.org/trac/boost/changeset/77755

Log:
Fixing LocalFunction to work in type-of emulation mode.
Text files modified:
   trunk/boost/local_function/aux_/config.hpp | 10 ++++++++++
   trunk/boost/local_function/aux_/function.hpp | 20 +++++++++++++-------
   trunk/libs/local_function/test/all_decl.cpp | 5 +++++
   trunk/libs/local_function/test/all_decl_seq.cpp | 5 +++++
   trunk/libs/local_function/test/factorial.cpp | 5 +++++
   trunk/libs/local_function/test/factorial_seq.cpp | 5 +++++
   6 files changed, 43 insertions(+), 7 deletions(-)

Modified: trunk/boost/local_function/aux_/config.hpp
==============================================================================
--- trunk/boost/local_function/aux_/config.hpp (original)
+++ trunk/boost/local_function/aux_/config.hpp 2012-04-04 11:35:30 EDT (Wed, 04 Apr 2012)
@@ -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

Modified: trunk/boost/local_function/aux_/function.hpp
==============================================================================
--- trunk/boost/local_function/aux_/function.hpp (original)
+++ trunk/boost/local_function/aux_/function.hpp 2012-04-04 11:35:30 EDT (Wed, 04 Apr 2012)
@@ -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 @@
 // 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

Modified: trunk/libs/local_function/test/all_decl.cpp
==============================================================================
--- trunk/libs/local_function/test/all_decl.cpp (original)
+++ trunk/libs/local_function/test/all_decl.cpp 2012-04-04 11:35:30 EDT (Wed, 04 Apr 2012)
@@ -11,6 +11,11 @@
 #else
 
 #include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#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 {

Modified: trunk/libs/local_function/test/all_decl_seq.cpp
==============================================================================
--- trunk/libs/local_function/test/all_decl_seq.cpp (original)
+++ trunk/libs/local_function/test/all_decl_seq.cpp 2012-04-04 11:35:30 EDT (Wed, 04 Apr 2012)
@@ -6,6 +6,11 @@
 // Home at http://www.boost.org/libs/local_function
 
 #include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#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 {

Modified: trunk/libs/local_function/test/factorial.cpp
==============================================================================
--- trunk/libs/local_function/test/factorial.cpp (original)
+++ trunk/libs/local_function/test/factorial.cpp 2012-04-04 11:35:30 EDT (Wed, 04 Apr 2012)
@@ -11,10 +11,15 @@
 #else
 
 #include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
 #include <boost/detail/lightweight_test.hpp>
 #include <algorithm>
 #include <vector>
 
+struct calculator;
+BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before bind `this_` below.
+
 //[factorial
 struct calculator {
     std::vector<int> results;

Modified: trunk/libs/local_function/test/factorial_seq.cpp
==============================================================================
--- trunk/libs/local_function/test/factorial_seq.cpp (original)
+++ trunk/libs/local_function/test/factorial_seq.cpp 2012-04-04 11:35:30 EDT (Wed, 04 Apr 2012)
@@ -6,10 +6,15 @@
 // Home at http://www.boost.org/libs/local_function
 
 #include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
 #include <boost/detail/lightweight_test.hpp>
 #include <algorithm>
 #include <vector>
 
+struct calculator;
+BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before bind `this_` below.
+
 struct calculator {
     std::vector<int> results;
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk