Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77965 - in trunk: boost libs/local_function/test
From: lorcaminiti_at_[hidden]
Date: 2012-04-13 19:14:49


Author: lcaminiti
Date: 2012-04-13 19:14:48 EDT (Fri, 13 Apr 2012)
New Revision: 77965
URL: http://svn.boost.org/trac/boost/changeset/77965

Log:
Fixed a bug with expansion of LocalFunction Id.
Text files modified:
   trunk/boost/local_function.hpp | 30 ++++++++++++++++++++----------
   trunk/libs/local_function/test/same_line.cpp | 6 +++---
   trunk/libs/local_function/test/same_line_seq.cpp | 12 +++++-------
   3 files changed, 28 insertions(+), 20 deletions(-)

Modified: trunk/boost/local_function.hpp
==============================================================================
--- trunk/boost/local_function.hpp (original)
+++ trunk/boost/local_function.hpp 2012-04-13 19:14:48 EDT (Fri, 13 Apr 2012)
@@ -21,33 +21,43 @@
 // PUBLIC //
 
 #ifdef BOOST_NO_VARIADIC_MACROS
-# define BOOST_LOCAL_FUNCTION(declarations) \
+# define BOOST_LOCAL_FUNCTION_ID(id, declarations) \
         BOOST_LOCAL_FUNCTION_AUX_DECL(id, 0 /* not within template */, \
                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
                         BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST( \
                                 declarations)))
-# define BOOST_LOCAL_FUNCTION_TPL(declarations) \
+# define BOOST_LOCAL_FUNCTION(declarations) \
+ BOOST_LOCAL_FUNCTION_ID( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, declarations)
+# define BOOST_LOCAL_FUNCTION_TPL_ID(id, declarations) \
         BOOST_LOCAL_FUNCTION_AUX_DECL(id, 1 /* within template */, \
                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
                         BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST( \
                                 declarations)))
+# define BOOST_LOCAL_FUNCTION_TPL(declarations) \
+ BOOST_LOCAL_FUNCTION_TPL_ID( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, declarations)
 #else // VARIADIC
-# define BOOST_LOCAL_FUNCTION(...) \
+# define BOOST_LOCAL_FUNCTION_ID(id, ...) \
         BOOST_LOCAL_FUNCTION_AUX_DECL(id, 0 /* not within template */, \
                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
                         BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__)))
-# define BOOST_LOCAL_FUNCTION_TPL(...) \
+# define BOOST_LOCAL_FUNCTION(...) \
+ BOOST_LOCAL_FUNCTION_ID( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, __VA_ARGS__)
+# define BOOST_LOCAL_FUNCTION_TPL_ID(id, ...) \
         BOOST_LOCAL_FUNCTION_AUX_DECL(id, 1 /* within template */, \
                 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
                         BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__)))
+# define BOOST_LOCAL_FUNCTION_TPL(...) \
+ BOOST_LOCAL_FUNCTION_TPL_ID( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, __VA_ARGS__)
 #endif // VARIADIC
 
-#define BOOST_LOCAL_FUNCTION_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_NAME(qualified_name) \
+ BOOST_LOCAL_FUNCTION_AUX_NAME(0 /* not within template */, qualified_name)
+#define BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_name) \
+ BOOST_LOCAL_FUNCTION_AUX_NAME(1 /* within template */, qualified_name)
 
 #define BOOST_LOCAL_FUNCTION_TYPEOF(bound_variable_name) \
     BOOST_LOCAL_FUNCTION_AUX_TYPEOF_TYPE(bound_variable_name)

Modified: trunk/libs/local_function/test/same_line.cpp
==============================================================================
--- trunk/libs/local_function/test/same_line.cpp (original)
+++ trunk/libs/local_function/test/same_line.cpp 2012-04-13 19:14:48 EDT (Fri, 13 Apr 2012)
@@ -31,15 +31,15 @@
     int BOOST_LOCAL_FUNCTION_TPL_ID(BOOST_PP_CAT(inc, __LINE__), \
             const bind offset, const int x) { \
         return x + offset; \
- } BOOST_LOCAL_FUNCTION_NAME(inc) \
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(inc) \
     \
     int BOOST_LOCAL_FUNCTION_TPL_ID(BOOST_PP_CAT(dec, __LINE__), \
             const bind offset, const int x) { \
         return x - offset; \
- } BOOST_LOCAL_FUNCTION_NAME(dec)
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(dec)
 
 template<typename T>
-void f(int delta) {
+void f(T const& delta) {
     LOCAL_INC_DEC_TPL(delta) // Multiple local functions on same line.
     /** @todo back to BOOST_TEST(dec(inc(123)) == 123)) and doc that on vacpp compiler composition doesn't work */
     BOOST_TEST(inc(123) == 123 + delta);

Modified: trunk/libs/local_function/test/same_line_seq.cpp
==============================================================================
--- trunk/libs/local_function/test/same_line_seq.cpp (original)
+++ trunk/libs/local_function/test/same_line_seq.cpp 2012-04-13 19:14:48 EDT (Fri, 13 Apr 2012)
@@ -11,14 +11,12 @@
 #include <iostream>
     
 #define LOCAL_INC_DEC(offset) \
- int BOOST_LOCAL_FUNCTION_ID( \
- BOOST_PP_CAT(inc, __LINE__) /* unique ID */, 0 /* no TPL */, \
+ int BOOST_LOCAL_FUNCTION_ID(BOOST_PP_CAT(inc, __LINE__), /* unique ID */ \
             (const bind offset) (const int x) ) { \
         return x + offset; \
     } BOOST_LOCAL_FUNCTION_NAME(inc) \
     \
- int BOOST_LOCAL_FUNCTION_ID( \
- BOOST_PP_CAT(dec, __LINE__) /* unique ID */, 0 /* no TPL */, \
+ int BOOST_LOCAL_FUNCTION_ID(BOOST_PP_CAT(dec, __LINE__), \
             (const bind offset) (const int x) ) { \
         return x - offset; \
     } BOOST_LOCAL_FUNCTION_NAME(dec)
@@ -27,15 +25,15 @@
     int BOOST_LOCAL_FUNCTION_TPL_ID(BOOST_PP_CAT(inc, __LINE__), \
             (const bind offset) (const int x) ) { \
         return x + offset; \
- } BOOST_LOCAL_FUNCTION_NAME(inc) \
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(inc) \
     \
     int BOOST_LOCAL_FUNCTION_TPL_ID(BOOST_PP_CAT(dec, __LINE__), \
             (const bind offset) (const int x) ) { \
         return x - offset; \
- } BOOST_LOCAL_FUNCTION_NAME(dec)
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(dec)
 
 template<typename T>
-void f(int delta) {
+void f(T const& delta) {
     LOCAL_INC_DEC_TPL(delta) // Multiple local functions on same line.
     /** @todo back to BOOST_TEST(dec(inc(123)) == 123)) and doc that on vacpp compiler composition doesn't work */
     BOOST_TEST(inc(123) == 123 + delta);


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