Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75415 - in trunk/boost/parameter: . aux_
From: daniel_at_[hidden]
Date: 2011-11-08 16:57:29


Author: danielw
Date: 2011-11-08 16:57:28 EST (Tue, 08 Nov 2011)
New Revision: 75415
URL: http://svn.boost.org/trac/boost/changeset/75415

Log:
Allow placeholder expressions in the type requirements for BOOST_PARAMETER_FUNCTION et al:

  (root_vertex
     , (vertex_descriptor<graphs::graph::_>)
     , *vertices(graph).first)

Text files modified:
   trunk/boost/parameter/aux_/cast.hpp | 44 +++++++++++++++++++++++++--------------
   trunk/boost/parameter/preprocessor.hpp | 3 ++
   2 files changed, 31 insertions(+), 16 deletions(-)

Modified: trunk/boost/parameter/aux_/cast.hpp
==============================================================================
--- trunk/boost/parameter/aux_/cast.hpp (original)
+++ trunk/boost/parameter/aux_/cast.hpp 2011-11-08 16:57:28 EST (Tue, 08 Nov 2011)
@@ -40,11 +40,11 @@
 // X(something, *(predicate))
 // X(something, (int))
 
-template <class T>
+template <class T, class Args>
 struct cast;
 
-template <>
-struct cast<void*>
+template <class Args>
+struct cast<void*, Args>
 {
     static use_default_tag execute(use_default_tag)
     {
@@ -73,27 +73,39 @@
 
 typedef void* voidstar;
 
-template <class T>
-struct cast<voidstar(T)>
- : cast<void*>
+template <class T, class Args>
+struct cast<voidstar(T), Args>
+ : cast<void*, Args>
 {
 };
 
 #else
 
-template <class T>
-struct cast<void*(T)>
- : cast<void*>
+template <class T, class Args>
+struct cast<void*(T), Args>
+ : cast<void*, Args>
 {
 };
 
 #endif
 
-template <class T>
-struct cast<void(T)>
+// This is a hack used in cast<> to turn the user supplied type,
+// which may or may not be a placeholder expression into one, so
+// that it will be properly evaluated by mpl::apply.
+template <class T, class Dummy = mpl::_1>
+struct as_placeholder_expr
 {
+ typedef T type;
+};
+
+template <class T, class Args>
+struct cast<void(T), Args>
+{
+ typedef typename mpl::apply2<
+ as_placeholder_expr<T>, Args, Args>::type type0;
+
     typedef typename boost::add_reference<
- typename boost::remove_const<T>::type
+ typename boost::remove_const<type0>::type
>::type reference;
 
     static use_default_tag execute(use_default_tag)
@@ -106,7 +118,7 @@
         return use_default_tag();
     }
 
- static T execute(T value)
+ static type0 execute(type0 value)
     {
         return value;
     }
@@ -118,9 +130,9 @@
     }
 };
 
-# define BOOST_PARAMETER_FUNCTION_CAST(value, predicate) \
- boost::parameter::aux::cast<void predicate>::remove_const( \
- boost::parameter::aux::cast<void predicate>::execute(value) \
+# define BOOST_PARAMETER_FUNCTION_CAST(value, predicate, args) \
+ boost::parameter::aux::cast<void predicate, args>::remove_const( \
+ boost::parameter::aux::cast<void predicate, args>::execute(value) \
     )
 
 # endif

Modified: trunk/boost/parameter/preprocessor.hpp
==============================================================================
--- trunk/boost/parameter/preprocessor.hpp (original)
+++ trunk/boost/parameter/preprocessor.hpp 2011-11-08 16:57:28 EST (Tue, 08 Nov 2011)
@@ -701,6 +701,7 @@
             ) \
         ] \
       , BOOST_PARAMETER_FN_ARG_PRED(arg) \
+ , Args \
     )
 
 # define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_BODY(name, n, split_args, tag_namespace) \
@@ -728,6 +729,7 @@
     BOOST_PARAMETER_FUNCTION_CAST( \
         boost::parameter::aux::as_lvalue(BOOST_PARAMETER_FN_ARG_DEFAULT(arg), 0L) \
       , BOOST_PARAMETER_FN_ARG_PRED(arg) \
+ , Args \
     )
 
 # define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT_BODY(name, n, split_args, tag_ns, const_) \
@@ -843,6 +845,7 @@
               boost::parameter::keyword<tag_ns::BOOST_PARAMETER_FN_ARG_KEYWORD(arg)>::instance \
           ] \
         , BOOST_PARAMETER_FN_ARG_PRED(arg) \
+ , Args \
       )
 
 // Generates the function template that recives a ArgumentPack, and then


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