Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70999 - in branches/pplib/variadics: boost/preprocessor/facilities libs/preprocessor/test
From: eldiener_at_[hidden]
Date: 2011-04-05 08:15:39


Author: eldiener
Date: 2011-04-05 08:15:38 EDT (Tue, 05 Apr 2011)
New Revision: 70999
URL: http://svn.boost.org/trac/boost/changeset/70999

Log:
Updated overload, and updated tests.
Text files modified:
   branches/pplib/variadics/boost/preprocessor/facilities/overload.hpp | 42 ++++++++++++++++++++++++++++++++++++++-
   branches/pplib/variadics/libs/preprocessor/test/Jamfile.v2 | 18 +++++++++++++++++
   branches/pplib/variadics/libs/preprocessor/test/array.cpp | 39 +++++++++++++++++++++++++++++++++++++
   branches/pplib/variadics/libs/preprocessor/test/list.cpp | 5 ++++
   branches/pplib/variadics/libs/preprocessor/test/seq.cpp | 3 ++
   branches/pplib/variadics/libs/preprocessor/test/tuple.cpp | 15 ++++++++++++++
   6 files changed, 120 insertions(+), 2 deletions(-)

Modified: branches/pplib/variadics/boost/preprocessor/facilities/overload.hpp
==============================================================================
--- branches/pplib/variadics/boost/preprocessor/facilities/overload.hpp (original)
+++ branches/pplib/variadics/boost/preprocessor/facilities/overload.hpp 2011-04-05 08:15:38 EDT (Tue, 05 Apr 2011)
@@ -17,12 +17,50 @@
 #
 #if BOOST_PP_VARIADICS
 #
-# include <boost/preprocessor/variadic/size.hpp>
+# include <boost/preprocessor/config/config.hpp>
+#
+# /* BOOST_PP_OVERLOAD detail macros */
+#
+#define BOOST_PP_OV_DETAIL_APPLY_VAR_I(macro, args) \
+ macro args \
+/**/
+#define BOOST_PP_OV_DETAIL_APPLY_VAR(macro, args) \
+ BOOST_PP_OV_DETAIL_APPLY_VAR_I(macro, args) \
+/**/
+#
+#define BOOST_PP_OV_DETAIL_ARG_N( \
+ A1,A2,A3,A4,A5,A6,A7,A8,A9,A10, \
+ A11,A12,A13,A14,A15,A16,A17,A18,A19,A20, \
+ A21,A22,A23,A24,N,...) N \
+/**/
+#define BOOST_PP_OV_DETAIL_RSEQ_N() \
+ 24,23,22,21,20, \
+ 19,18,17,16,15,14,13,12,11,10, \
+ 9,8,7,6,5,4,3,2,1,0 \
+/**/
+#
+# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()
+# define BOOST_PP_OV_DETAIL_CAT(a, b) BOOST_PP_OV_DETAIL_CAT_I(a, b)
+# define BOOST_PP_OV_DETAIL_CAT_I(a, b) BOOST_PP_OV_DETAIL_CAT_II(a ## b)
+# define BOOST_PP_OV_DETAIL_CAT_II(res) res
+# include <boost/preprocessor/facilities/empty.hpp>
+#define BOOST_PP_OV_DETAIL_SIZE(...) \
+ BOOST_PP_OV_DETAIL_CAT(BOOST_PP_OV_DETAIL_APPLY_VAR(BOOST_PP_OV_DETAIL_ARG_N, (__VA_ARGS__, BOOST_PP_OV_DETAIL_RSEQ_N())),BOOST_PP_EMPTY()) \
+/**/
+#else
+#define BOOST_PP_OV_DETAIL_SIZE(...) \
+ BOOST_PP_OV_DETAIL_APPLY_VAR(BOOST_PP_OV_DETAIL_ARG_N, (__VA_ARGS__, BOOST_PP_OV_DETAIL_RSEQ_N())) \
+/**/
+#endif
+#
+#define BOOST_PP_OV_SIZE(...) \
+ BOOST_PP_OV_DETAIL_SIZE(__VA_ARGS__) \
+/**/
 #
 # /* BOOST_PP_OVERLOAD */
 #
 #define BOOST_PP_OVERLOAD(prefix, ...) \
- BOOST_PP_OV_CAT(prefix, BOOST_PP_VARIADIC_SIZE(__VA_ARGS__)) \
+ BOOST_PP_OV_CAT(prefix, BOOST_PP_OV_SIZE(__VA_ARGS__)) \
 /**/
 #
 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()

Modified: branches/pplib/variadics/libs/preprocessor/test/Jamfile.v2
==============================================================================
--- branches/pplib/variadics/libs/preprocessor/test/Jamfile.v2 (original)
+++ branches/pplib/variadics/libs/preprocessor/test/Jamfile.v2 2011-04-05 08:15:38 EDT (Tue, 05 Apr 2011)
@@ -34,3 +34,21 @@
         [ compile slot.cpp ]
         [ compile tuple.cpp ]
   ;
+
+test-suite preprocessor_nvm
+ :
+ [ compile arithmetic.cpp : <define>BOOST_PP_VARIADICS=0 : arithmetic_nvm ]
+ [ compile array.cpp : <define>BOOST_PP_VARIADICS=0 : array_nvm ]
+ [ compile comparison.cpp : <define>BOOST_PP_VARIADICS=0 : comparison_nvm ]
+ [ compile control.cpp : <define>BOOST_PP_VARIADICS=0 : control_nvm ]
+ [ compile debug.cpp : <define>BOOST_PP_VARIADICS=0 : debug_nvm ]
+ [ compile facilities.cpp : <define>BOOST_PP_VARIADICS=0 : facilities_nvm ]
+ [ compile iteration.cpp : <define>BOOST_PP_VARIADICS=0 : iteration_nvm ]
+ [ compile list.cpp : <define>BOOST_PP_VARIADICS=0 : list_nvm ]
+ [ compile logical.cpp : <define>BOOST_PP_VARIADICS=0 : logical_nvm ]
+ [ compile repetition.cpp : <define>BOOST_PP_VARIADICS=0 : repetition_nvm ]
+ [ compile selection.cpp : <define>BOOST_PP_VARIADICS=0 : selection_nvm ]
+ [ compile seq.cpp : <define>BOOST_PP_VARIADICS=0 : seq_nvm ]
+ [ compile slot.cpp : <define>BOOST_PP_VARIADICS=0 : slot_nvm ]
+ [ compile tuple.cpp : <define>BOOST_PP_VARIADICS=0 : tuple_nvm ]
+ ;

Modified: branches/pplib/variadics/libs/preprocessor/test/array.cpp
==============================================================================
--- branches/pplib/variadics/libs/preprocessor/test/array.cpp (original)
+++ branches/pplib/variadics/libs/preprocessor/test/array.cpp 2011-04-05 08:15:38 EDT (Tue, 05 Apr 2011)
@@ -11,6 +11,12 @@
 #
 # include <boost/preprocessor/array.hpp>
 # include <libs/preprocessor/test/test.h>
+# include <boost/preprocessor/list/at.hpp>
+# include <boost/preprocessor/seq/elem.hpp>
+# include <boost/preprocessor/tuple/elem.hpp>
+# if BOOST_PP_VARIADICS
+# include <boost/preprocessor/variadic/elem.hpp>
+# endif
 
 # define ARRAY (3, (0, 1, 2))
 
@@ -23,3 +29,36 @@
 
 BEGIN BOOST_PP_ARRAY_SIZE(ARRAY) == 3 END
 BEGIN BOOST_PP_ARRAY_SIZE((5, (0, 1, 2, 3, 4))) == 5 END
+
+// enum
+
+# if BOOST_PP_VARIADICS
+
+BEGIN BOOST_PP_VARIADIC_ELEM(2,BOOST_PP_ARRAY_ENUM(ARRAY)) == 2 END
+BEGIN BOOST_PP_VARIADIC_ELEM(3,BOOST_PP_ARRAY_ENUM((5, (0, 1, 2, 3, 4)))) == 3 END
+
+# endif
+
+// to_list
+
+BEGIN BOOST_PP_LIST_AT(BOOST_PP_ARRAY_TO_LIST(ARRAY), 1) == 1 END
+BEGIN BOOST_PP_LIST_AT(BOOST_PP_ARRAY_TO_LIST((5, (0, 1, 2, 3, 4))), 4) == 4 END
+
+// to_seq
+
+BEGIN BOOST_PP_SEQ_ELEM(0, BOOST_PP_ARRAY_TO_SEQ(ARRAY)) == 0 END
+BEGIN BOOST_PP_SEQ_ELEM(3, BOOST_PP_ARRAY_TO_SEQ((5, (0, 1, 2, 3, 4)))) == 3 END
+
+// to_tuple
+
+# if BOOST_PP_VARIADICS
+
+BEGIN BOOST_PP_TUPLE_ELEM(2, BOOST_PP_ARRAY_TO_TUPLE(ARRAY)) == 2 END
+BEGIN BOOST_PP_TUPLE_ELEM(1, BOOST_PP_ARRAY_TO_TUPLE((5, (0, 1, 2, 3, 4)))) == 1 END
+
+# else
+
+BEGIN BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_ARRAY_TO_TUPLE(ARRAY)) == 2 END
+BEGIN BOOST_PP_TUPLE_ELEM(5, 1, BOOST_PP_ARRAY_TO_TUPLE((5, (0, 1, 2, 3, 4)))) == 1 END
+
+# endif

Modified: branches/pplib/variadics/libs/preprocessor/test/list.cpp
==============================================================================
--- branches/pplib/variadics/libs/preprocessor/test/list.cpp (original)
+++ branches/pplib/variadics/libs/preprocessor/test/list.cpp 2011-04-05 08:15:38 EDT (Tue, 05 Apr 2011)
@@ -14,6 +14,8 @@
 # include <boost/preprocessor/comparison/less.hpp>
 # include <boost/preprocessor/list.hpp>
 # include <boost/preprocessor/tuple/elem.hpp>
+# include <boost/preprocessor/array/elem.hpp>
+# include <boost/preprocessor/seq/elem.hpp>
 # include <libs/preprocessor/test/test.h>
 
 # define LIST (4, (1, (5, (2, BOOST_PP_NIL))))
@@ -52,3 +54,6 @@
 # define LL (L1, (L2, (L3, BOOST_PP_NIL)))
 
 BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_LIST_APPEND_D, BOOST_PP_NIL, LL)) == 0x0a1b2c3d END
+
+BEGIN BOOST_PP_ARRAY_ELEM(2, BOOST_PP_LIST_TO_ARRAY(LIST)) == 5 END
+BEGIN BOOST_PP_SEQ_ELEM(3, BOOST_PP_LIST_TO_SEQ(LIST)) == 2 END

Modified: branches/pplib/variadics/libs/preprocessor/test/seq.cpp
==============================================================================
--- branches/pplib/variadics/libs/preprocessor/test/seq.cpp (original)
+++ branches/pplib/variadics/libs/preprocessor/test/seq.cpp 2011-04-05 08:15:38 EDT (Tue, 05 Apr 2011)
@@ -14,6 +14,7 @@
 # include <boost/preprocessor/comparison/less.hpp>
 # include <boost/preprocessor/seq.hpp>
 # include <boost/preprocessor/tuple/elem.hpp>
+# include <boost/preprocessor/list/at.hpp>
 # include <libs/preprocessor/test/test.h>
 
 # define SEQ (4)(1)(5)(2)
@@ -83,3 +84,5 @@
 #define SEQ_APPEND(s, state, elem) state elem
 BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_TAIL(BOOST_PP_SEQ_FOLD_LEFT(SEQ_APPEND, (~), LL))) == 0x0a1b2c3d END
 BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_TAIL(BOOST_PP_SEQ_FOLD_LEFT(SEQ_APPEND, (~), LL))) == 9 END
+
+BEGIN BOOST_PP_LIST_AT(BOOST_PP_SEQ_TO_LIST(SEQ), 2) == 5 END

Modified: branches/pplib/variadics/libs/preprocessor/test/tuple.cpp
==============================================================================
--- branches/pplib/variadics/libs/preprocessor/test/tuple.cpp (original)
+++ branches/pplib/variadics/libs/preprocessor/test/tuple.cpp 2011-04-05 08:15:38 EDT (Tue, 05 Apr 2011)
@@ -10,6 +10,9 @@
 # /* See http://www.boost.org for most recent version. */
 #
 # include <boost/preprocessor/tuple.hpp>
+# include <boost/preprocessor/arithmetic/add.hpp>
+# include <boost/preprocessor/cat.hpp>
+# include <boost/preprocessor/control/if.hpp>
 # include <libs/preprocessor/test/test.h>
 
 # define TUPLE (0, 1, 2, 3, 4, 5)
@@ -40,3 +43,15 @@
 BEGIN CALC(BOOST_PP_TUPLE_REVERSE(T2)) == 6 END
 
 #endif
+
+#if BOOST_PP_VARIADICS
+
+#define TEST_EAT BOOST_PP_TUPLE_EAT()(1, 2) 4
+
+#else
+
+#define TEST_EAT BOOST_PP_TUPLE_EAT(2)(1, 2) 4
+
+#endif
+
+BEGIN TEST_EAT == 4 END


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