Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54524 - in trunk/boost/proto: context detail transform
From: eric_at_[hidden]
Date: 2009-06-30 02:14:19


Author: eric_niebler
Date: 2009-06-30 02:14:18 EDT (Tue, 30 Jun 2009)
New Revision: 54524
URL: http://svn.boost.org/trac/boost/changeset/54524

Log:
unbreak example/lambda.hpp's handling of member pointers
Text files modified:
   trunk/boost/proto/context/default.hpp | 26 ++++++++------
   trunk/boost/proto/detail/decltype.hpp | 71 ++++++++++++++++++++++++++++++++-------
   trunk/boost/proto/transform/default.hpp | 24 +++++++-----
   3 files changed, 87 insertions(+), 34 deletions(-)

Modified: trunk/boost/proto/context/default.hpp
==============================================================================
--- trunk/boost/proto/context/default.hpp (original)
+++ trunk/boost/proto/context/default.hpp 2009-06-30 02:14:18 EDT (Tue, 30 Jun 2009)
@@ -137,13 +137,19 @@
             /// INTERNAL ONLY
             template<typename Expr, typename Context>
             struct is_member_function_eval
- {
- typedef typename proto::result_of::child_c<Expr, 1>::type e1;
- typedef typename proto::result_of::eval<UNREF(e1), Context>::type r1;
- typedef typename remove_const<typename remove_reference<r1>::type>::type uncvref_r1;
- typedef typename is_member_function_pointer<uncvref_r1>::type type;
- BOOST_STATIC_CONSTANT(bool, value = type::value);
- };
+ : is_member_function_pointer<
+ typename remove_const<
+ typename remove_reference<
+ typename proto::result_of::eval<
+ typename remove_reference<
+ typename proto::result_of::child_c<Expr, 1>::type
+ >::type
+ , Context
+ >::type
+ >::type
+ >::type
+ >
+ {};
 
             /// INTERNAL ONLY
             template<typename Expr, typename Context, bool IsMemFunCall>
@@ -154,12 +160,11 @@
                 typedef typename result_of::child_c<Expr, 1>::type e1;
                 typedef typename proto::result_of::eval<UNREF(e0), Context>::type r0;
                 typedef typename proto::result_of::eval<UNREF(e1), Context>::type r1;
- typedef typename remove_const<typename remove_reference<r1>::type>::type uncvref_r1;
             public:
- typedef typename detail::mem_ptr_fun<r0, uncvref_r1>::result_type result_type;
+ typedef typename detail::mem_ptr_fun<r0, r1>::result_type result_type;
                 result_type operator ()(Expr &expr, Context &ctx) const
                 {
- return detail::mem_ptr_fun<r0, uncvref_r1>()(
+ return detail::mem_ptr_fun<r0, r1>()(
                         proto::eval(proto::child_c<0>(expr), ctx)
                       , proto::eval(proto::child_c<1>(expr), ctx)
                     );
@@ -175,7 +180,6 @@
                 typedef typename result_of::child_c<Expr, 1>::type e1;
                 typedef typename proto::result_of::eval<UNREF(e0), Context>::type r0;
                 typedef typename proto::result_of::eval<UNREF(e1), Context>::type r1;
- typedef typename remove_const<typename remove_reference<r1>::type>::type uncvref_r1;
             public:
                 typedef detail::memfun<r0, r1> result_type;
                 result_type const operator ()(Expr &expr, Context &ctx) const

Modified: trunk/boost/proto/detail/decltype.hpp
==============================================================================
--- trunk/boost/proto/detail/decltype.hpp (original)
+++ trunk/boost/proto/detail/decltype.hpp 2009-06-30 02:14:18 EDT (Tue, 30 Jun 2009)
@@ -15,8 +15,10 @@
 #include <boost/get_pointer.hpp>
 #include <boost/preprocessor/cat.hpp>
 #include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#include <boost/preprocessor/iteration/local.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/mpl/eval_if.hpp>
 #include <boost/mpl/identity.hpp>
@@ -255,6 +257,21 @@
             typedef U type;
         };
 
+ #define BOOST_PP_LOCAL_MACRO(N) \
+ template<typename T, typename U BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)> \
+ struct classtypeof<T (U::*)(BOOST_PP_ENUM_PARAMS(N, A))> \
+ { \
+ typedef U type; \
+ }; \
+ template<typename T, typename U BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)> \
+ struct classtypeof<T (U::*)(BOOST_PP_ENUM_PARAMS(N, A)) const> \
+ { \
+ typedef U type; \
+ }; \
+ /**/
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PROTO_MAX_ARITY)
+ #include BOOST_PP_LOCAL_ITERATE()
+
         ////////////////////////////////////////////////////////////////////////////////////////////
         template<typename T>
         T &lvalue(T &t)
@@ -356,20 +373,49 @@
             };
 
             ////////////////////////////////////////////////////////////////////////////////////////////
- template<typename T, typename U>
- struct mem_ptr_fun;
+ template<
+ typename T
+ , typename U
+ , bool IsMemPtr = is_member_object_pointer<
+ typename remove_reference<U>::type
+ >::value
+ >
+ struct mem_ptr_fun
+ {
+ BOOST_PROTO_DECLTYPE_(
+ proto::detail::make_mutable<T>() ->* proto::detail::make<U>()
+ , result_type
+ )
 
- template<typename T, typename U, typename V>
- struct mem_ptr_fun<T, U V::*>
+ result_type operator()(
+ typename add_reference<typename add_const<T>::type>::type t
+ , typename add_reference<typename add_const<U>::type>::type u
+ ) const
+ {
+ return t ->* u;
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename T, typename U>
+ struct mem_ptr_fun<T, U, true>
             {
+ typedef
+ typename classtypeof<
+ typename remove_const<
+ typename remove_reference<U>::type
+ >::type
+ >::type
+ V;
+
                 BOOST_PROTO_DECLTYPE_(
- BOOST_PROTO_GET_POINTER(V, proto::detail::make_mutable<T>()) ->* proto::detail::make<U V::*>()
+ BOOST_PROTO_GET_POINTER(V, proto::detail::make_mutable<T>()) ->* proto::detail::make<U>()
                   , result_type
                 )
 
                 result_type operator()(
                     typename add_reference<typename add_const<T>::type>::type t
- , U V::*u
+ , U u
                 ) const
                 {
                     return BOOST_PROTO_GET_POINTER(V, t) ->* u;
@@ -450,14 +496,13 @@
         //BOOST_MPL_ASSERT((is_same<void(*)(), result_of_fixup<void(&)()>::type>));
 
         template<typename T, typename PMF>
- struct memfun;
-
- template<typename T, typename U, typename V>
- struct memfun<T, U V::*>
+ struct memfun
         {
- typedef typename boost::result_of<U V::*(T)>::type result_type;
+ typedef typename remove_const<typename remove_reference<PMF>::type>::type pmf_type;
+ typedef typename classtypeof<pmf_type>::type V;
+ typedef typename boost::result_of<pmf_type(T)>::type result_type;
 
- memfun(T t, U V::*p)
+ memfun(T t, PMF p)
               : obj(t)
               , pmf(p)
             {}
@@ -482,7 +527,7 @@
 
         private:
             T obj;
- U V::*pmf;
+ PMF pmf;
         };
 
     } // namespace detail

Modified: trunk/boost/proto/transform/default.hpp
==============================================================================
--- trunk/boost/proto/transform/default.hpp (original)
+++ trunk/boost/proto/transform/default.hpp 2009-06-30 02:14:18 EDT (Tue, 30 Jun 2009)
@@ -140,13 +140,18 @@
             /// INTERNAL ONLY
             template<typename Expr, typename State, typename Data>
             struct is_member_function_invocation
- {
- typedef typename result_of::child_c<Expr, 1>::type e1;
- typedef typename Grammar::template impl<e1, State, Data>::result_type r1;
- typedef typename remove_const<typename remove_reference<r1>::type>::type uncvref_r1;
- typedef typename is_member_function_pointer<uncvref_r1>::type type;
- BOOST_STATIC_CONSTANT(bool, value = type::value);
- };
+ : is_member_function_pointer<
+ typename remove_const<
+ typename remove_reference<
+ typename Grammar::template impl<
+ typename result_of::child_c<Expr, 1>::type
+ , State
+ , Data
+ >::result_type
+ >::type
+ >::type
+ >
+ {};
 
             /// INTERNAL ONLY
             template<typename Expr, typename State, typename Data, bool IsMemFunCall>
@@ -158,9 +163,8 @@
                 typedef typename result_of::child_c<Expr, 1>::type e1;
                 typedef typename Grammar::template impl<e0, State, Data>::result_type r0;
                 typedef typename Grammar::template impl<e1, State, Data>::result_type r1;
- typedef typename remove_const<typename remove_reference<r1>::type>::type uncvref_r1;
             public:
- typedef typename detail::mem_ptr_fun<r0, uncvref_r1>::result_type result_type;
+ typedef typename detail::mem_ptr_fun<r0, r1>::result_type result_type;
                 result_type operator ()(
                     typename memfun_impl::expr_param e
                   , typename memfun_impl::state_param s
@@ -169,7 +173,7 @@
                 {
                     typename Grammar::template impl<e0, State, Data> t0;
                     typename Grammar::template impl<e1, State, Data> t1;
- return detail::mem_ptr_fun<r0, uncvref_r1>()(
+ return detail::mem_ptr_fun<r0, r1>()(
                         t0(proto::child_c<0>(e), s, d)
                       , t1(proto::child_c<1>(e), s, d)
                     );


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