|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74496 - in sandbox/local: boost/detail/preprocessor/keyword/facility boost/detail/preprocessor/variadic_macro_data/detail boost/local/aux_/preprocessor/variadic boost/utility libs/local/doc/qbk
From: lorcaminiti_at_[hidden]
Date: 2011-09-21 14:01:49
Author: lcaminiti
Date: 2011-09-21 14:01:48 EDT (Wed, 21 Sep 2011)
New Revision: 74496
URL: http://svn.boost.org/trac/boost/changeset/74496
Log:
Committing some pp improvements(?) used to program contract library.
Text files modified:
sandbox/local/boost/detail/preprocessor/keyword/facility/is.hpp | 18 ++++++++++++++-
sandbox/local/boost/detail/preprocessor/keyword/facility/remove.hpp | 20 ++++++++++++++++-
sandbox/local/boost/detail/preprocessor/variadic_macro_data/detail/vmd_detail.hpp | 9 +++++++
sandbox/local/boost/local/aux_/preprocessor/variadic/is.hpp | 44 ++++++++++++++++++++++++++++++----------
sandbox/local/boost/utility/identity.hpp | 10 +++++++++
sandbox/local/libs/local/doc/qbk/local.qbk | 2
6 files changed, 86 insertions(+), 17 deletions(-)
Modified: sandbox/local/boost/detail/preprocessor/keyword/facility/is.hpp
==============================================================================
--- sandbox/local/boost/detail/preprocessor/keyword/facility/is.hpp (original)
+++ sandbox/local/boost/detail/preprocessor/keyword/facility/is.hpp 2011-09-21 14:01:48 EDT (Wed, 21 Sep 2011)
@@ -15,10 +15,24 @@
#include <boost/preprocessor/detail/is_unary.hpp>
#include <boost/preprocessor/cat.hpp>
+// PRIVATE //
+
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_IS_(a, b) \
+ BOOST_PP_IS_UNARY(BOOST_PP_CAT(a, b))
+
+// PUBLIC //
+
// `chekcing_prefix ## tokens` expand to unary (e.g., `(1)`) iff `tokens` start
// with keyword to check.
#define BOOST_DETAIL_PP_KEYWORD_FACILITY_IS_FRONT(tokens, checking_prefix) \
- BOOST_PP_IS_UNARY(BOOST_PP_CAT(checking_prefix, tokens))
+ BOOST_PP_IIF(BOOST_PP_IS_UNARY(tokens), \
+ /* on MSVC this check works even if tokens already unary but on */ \
+ /* ISO C++ (including GCC) this check on non-unary tokens gives */ \
+ /* a concatenation error -- so return false is tokens is not unary */ \
+ 0 BOOST_PP_TUPLE_EAT(2) \
+ , \
+ BOOST_DETAIL_PP_KEYWORD_FACILITY_IS_ \
+ )(checking_prefix, tokens)
// `token ## chekcing_postfix` expand to unary (e.g., `(1)`) iff `token` is the
// keyword to check. This check only works if `token` is a single token, it
@@ -26,7 +40,7 @@
// This check will expand to 0 with no error if `token` starts with a
// non-alphanumeric symbol (e.g., `*this`).
#define BOOST_DETAIL_PP_KEYWORD_FACILITY_IS_BACK(token, checking_postfix) \
- BOOST_PP_IS_UNARY(BOOST_PP_CAT(token, checking_postfix))
+ BOOST_DETAIL_PP_KEYWORD_FACILITY_IS_(token, checking_postfix)
#endif // #include guard
Modified: sandbox/local/boost/detail/preprocessor/keyword/facility/remove.hpp
==============================================================================
--- sandbox/local/boost/detail/preprocessor/keyword/facility/remove.hpp (original)
+++ sandbox/local/boost/detail/preprocessor/keyword/facility/remove.hpp 2011-09-21 14:01:48 EDT (Wed, 21 Sep 2011)
@@ -9,14 +9,30 @@
#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/tuple/eat.hpp>
-#include <boost/preprocessor/facilities/expand.hpp>
#include <boost/preprocessor/cat.hpp>
+// PRIVATE //
+
+// From PP_EXPAND (my own reentrant version).
+#if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() && ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC()
+# define BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT_EXPAND_(x) \
+ BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT_EXPAND_I_(x)
+#else
+# define BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT_EXPAND_(x) \
+ BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT_EXPAND_OO_((x))
+# define BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT_EXPAND_OO_(par) \
+ BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT_EXPAND_I_ ## par
+#endif
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT_EXPAND_I_(x) x
+
+// PUBLIC //
+
// `is_front_macro(tokens)` is 1 iff `tokens` start with keyword to remove.
// `removing_prefix ## <keyword-to-remove>` must expand to nothing.
#define BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT( \
tokens, is_front_macro, removing_prefix) \
- BOOST_PP_EXPAND( /* without EXPAND doesn't expand on MSVC */ \
+ /* without EXPAND doesn't expand on MSVC */ \
+ BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT_EXPAND_( \
BOOST_PP_IIF(is_front_macro(tokens), \
BOOST_PP_CAT \
, \
Modified: sandbox/local/boost/detail/preprocessor/variadic_macro_data/detail/vmd_detail.hpp
==============================================================================
--- sandbox/local/boost/detail/preprocessor/variadic_macro_data/detail/vmd_detail.hpp (original)
+++ sandbox/local/boost/detail/preprocessor/variadic_macro_data/detail/vmd_detail.hpp 2011-09-21 14:01:48 EDT (Wed, 21 Sep 2011)
@@ -124,8 +124,15 @@
BOOST_DETAIL_PP_VMD_DETAIL_REMOVE_TUPLE_PARENS tuple \
/**/
#if defined(BOOST_MSVC)
+# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() && ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC()
+# define BOOST_DETAIL_PP_VMD_DETAIL_DATA_SIZE_EXPAND(x) BOOST_DETAIL_PP_VMD_DETAIL_DATA_SIZE_EXPAND_I(x)
+# else
+# define BOOST_DETAIL_PP_VMD_DETAIL_DATA_SIZE_EXPAND(x) BOOST_DETAIL_PP_VMD_DETAIL_DATA_SIZE_EXPAND_OO((x))
+# define BOOST_DETAIL_PP_VMD_DETAIL_DATA_SIZE_EXPAND_OO(par) BOOST_DETAIL_PP_VMD_DETAIL_DATA_SIZE_EXPAND_I ## par
+# endif
+# define BOOST_DETAIL_PP_VMD_DETAIL_DATA_SIZE_EXPAND_I(x) x
#define BOOST_DETAIL_PP_VMD_DETAIL_DATA_SIZE(...) \
- BOOST_PP_ADD(BOOST_DETAIL_PP_VMD_DETAIL_APPLY(BOOST_DETAIL_PP_VMD_DETAIL_ARG_N, (__VA_ARGS__, BOOST_DETAIL_PP_VMD_DETAIL_RSEQ_N())),0) \
+ BOOST_DETAIL_PP_VMD_DETAIL_DATA_SIZE_EXPAND(BOOST_DETAIL_PP_VMD_DETAIL_APPLY(BOOST_DETAIL_PP_VMD_DETAIL_ARG_N, (__VA_ARGS__, BOOST_DETAIL_PP_VMD_DETAIL_RSEQ_N()))) \
/**/
#else
#define BOOST_DETAIL_PP_VMD_DETAIL_DATA_SIZE(...) \
Modified: sandbox/local/boost/local/aux_/preprocessor/variadic/is.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/preprocessor/variadic/is.hpp (original)
+++ sandbox/local/boost/local/aux_/preprocessor/variadic/is.hpp 2011-09-21 14:01:48 EDT (Wed, 21 Sep 2011)
@@ -13,26 +13,48 @@
#include "size.hpp"
#include "eat.hpp"
-#include <boost/preprocessor/logical/not.hpp>
-#include <boost/preprocessor/control/if.hpp>
-#include <boost/preprocessor/comparison/greater.hpp>
+#include <boost/preprocessor/logical/compl.hpp>
+#include <boost/preprocessor/control/iif.hpp>
+#include <boost/preprocessor/comparison/equal.hpp>
+#include <boost/preprocessor/tuple/elem.hpp>
// `IS_UNARY` not working on Borland and other pp which have no variadic anyway.
#include <boost/preprocessor/detail/is_unary.hpp>
// PRIVATE //
-#define BOOST_LOCAL_AUX_PP_IS_VARIADIC_NOT_UNARY_(...) \
- BOOST_PP_NOT(BOOST_PP_IS_UNARY(__VA_ARGS__))
+#define BOOST_LOCAL_AUX_PP_IS_VARIADIC_NOT_UNARY1_(tokens) \
+ BOOST_PP_COMPL(BOOST_PP_IS_UNARY(tokens))
+
+#define BOOST_LOCAL_AUX_PP_IS_VARIADIC_REMOVE1_(tokens) /* nothing */
+
+// Tokens `(t1) t2`.
+#define BOOST_LOCAL_AUX_PP_IS_VARIADIC_SKIP1_(tokens) \
+ BOOST_LOCAL_AUX_PP_IS_VARIADIC_NOT_UNARY1_( \
+ BOOST_LOCAL_AUX_PP_IS_VARIADIC_REMOVE1_ tokens \
+ (1) /* trailing unary handles empty */ \
+ )
+
+#define BOOST_LOCAL_AUX_PP_IS_VARIADIC_NOT_UNARY2_(tokens) \
+ BOOST_PP_IIF(BOOST_PP_IS_UNARY(tokens), \
+ BOOST_LOCAL_AUX_PP_IS_VARIADIC_SKIP1_ \
+ , \
+ 1 /* it is not unary */ \
+ BOOST_PP_TUPLE_EAT(1) \
+ )(tokens)
+
+#define BOOST_LOCAL_AUX_PP_IS_VARIADIC_(size, ...) \
+ BOOST_PP_IIF(BOOST_PP_EQUAL(size, 1), \
+ BOOST_LOCAL_AUX_PP_IS_VARIADIC_NOT_UNARY2_ \
+ , /* size == 0 or size > 1 (it's variadic) */ \
+ 1 \
+ BOOST_LOCAL_AUX_PP_VARIADIC_EAT \
+ )(__VA_ARGS__)
// PUBLIC //
#define BOOST_LOCAL_AUX_PP_IS_VARIADIC(...) \
- BOOST_PP_IF(BOOST_PP_GREATER( /* IIF does not expand on MSVC */ \
- BOOST_LOCAL_AUX_PP_VARIADIC_SIZE(__VA_ARGS__), 1), \
- 1 BOOST_LOCAL_AUX_PP_VARIADIC_EAT \
- , \
- BOOST_LOCAL_AUX_PP_IS_VARIADIC_NOT_UNARY_ \
- )(__VA_ARGS__)
+ BOOST_LOCAL_AUX_PP_IS_VARIADIC_( \
+ BOOST_LOCAL_AUX_PP_VARIADIC_SIZE(__VA_ARGS__), __VA_ARGS__)
#endif // BOOST_NO_VARIADIC_MACROS
Modified: sandbox/local/boost/utility/identity.hpp
==============================================================================
--- sandbox/local/boost/utility/identity.hpp (original)
+++ sandbox/local/boost/utility/identity.hpp 2011-09-21 14:01:48 EDT (Wed, 21 Sep 2011)
@@ -51,6 +51,16 @@
* contains a comma not wrapped by round parenthesis so it will be interpreted
* as two separate macro parameters by the preprocessor).
*
+ * On some compilers (like GCC), using this macro on abstract types (classes
+ * with one or more pure virtual functions) generate a compile-time error.
+ * This can be worked around by manipulating the type adding and removing a
+ * reference to it:
+ * @code
+ * boost::remove_reference< BOOST_IDENTITY_TYPE((boost::add_reference<
+ * my_abstract_type< int, double >
+ * >::type)) >::type
+ * @endcode
+ *
* @Params
* @Param{parenthesized_type,
* The type expression to be passed as macro parameter wrapped by a single set
Modified: sandbox/local/libs/local/doc/qbk/local.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/local.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/local.qbk 2011-09-21 14:01:48 EDT (Wed, 21 Sep 2011)
@@ -9,7 +9,7 @@
[version 0.2.0 ]
[/ purpose Local functions, blocks, and exits for C++]
[/ category Function Objects and Higher-Order Programming]
- [authors [Caminiti (lorcaminiti -at- gmail.com), Lorenzo]]
+ [authors [Caminiti <lorcaminiti-AT-gmail.com>, Lorenzo]]
[copyright 2009-2011 Lorenzo Caminiti]
[license
Use, modification, and distribution is subject to the
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