Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63068 - in sandbox/SOC/2010/phoenix3: boost/phoenix boost/phoenix/bind boost/phoenix/core boost/phoenix/operator libs/phoenix/test libs/phoenix/test/operator
From: thom.heller_at_[hidden]
Date: 2010-06-17 18:13:59


Author: theller
Date: 2010-06-17 18:13:58 EDT (Thu, 17 Jun 2010)
New Revision: 63068
URL: http://svn.boost.org/trac/boost/changeset/63068

Log:
+ Fixed issue with member object pointers and MSVC
+ Other minor tweaks

Added:
   sandbox/SOC/2010/phoenix3/boost/phoenix/bind/bind_member_variable.hpp (contents, props changed)
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/mem_obj_ptr.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/bind.hpp | 1
   sandbox/SOC/2010/phoenix3/boost/phoenix/bind/bind.hpp | 15 ++++++++++---
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/reference.hpp | 4 +-
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp | 30 ++++++++++++++++++++-------
   sandbox/SOC/2010/phoenix3/boost/phoenix/operator/member.hpp | 43 ++++++++++++++++++++++++++++++---------
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile | 2
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp | 2 +
   7 files changed, 72 insertions(+), 25 deletions(-)

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/bind.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/bind.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/bind.hpp 2010-06-17 18:13:58 EDT (Thu, 17 Jun 2010)
@@ -9,5 +9,6 @@
 
 #include <boost/phoenix/version.hpp>
 #include <boost/phoenix/bind/bind.hpp>
+#include <boost/phoenix/bind/bind_member_variable.hpp>
 
 #endif

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/bind/bind.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/bind/bind.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/bind/bind.hpp 2010-06-17 18:13:58 EDT (Thu, 17 Jun 2010)
@@ -22,8 +22,8 @@
     // Bind
     ////////////////////////////////////////////////////////////////////////////
     
- template<typename F>
- typename boost::result_of<function<F>()>::type
+ template <typename F>
+ typename boost::result_of<function<F>()>::type const
     bind(F f)
     {
         return function<F>(f)();
@@ -40,8 +40,15 @@
 
 #else
     
- template<typename F, PHOENIX_typename_A>
- typename boost::result_of<function<F>(PHOENIX_A_const_ref)>::type
+ template <typename F, PHOENIX_typename_A>
+#if PHOENIX_ITERATION == 1
+ typename disable_if<
+ is_member_object_pointer<F>
+ , typename boost::result_of<function<F>(A0 const&)>::type const
+ >::type
+#else
+ typename boost::result_of<function<F>(PHOENIX_A_const_ref)>::type const
+#endif
     bind(F f, PHOENIX_A_const_ref_a)
     {
         return function<F>(f)(PHOENIX_a);

Added: sandbox/SOC/2010/phoenix3/boost/phoenix/bind/bind_member_variable.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/bind/bind_member_variable.hpp 2010-06-17 18:13:58 EDT (Thu, 17 Jun 2010)
@@ -0,0 +1,32 @@
+/*==============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2010 Thomas Heller
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef PHOENIX_BIND_BIND_MEMBER_VARIABLE_HPP
+#define PHOENIX_BIND_BIND_MEMBER_VARIABLE_HPP
+
+#include <boost/phoenix/core/mem_obj_ptr.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Bind - overload for member object pointers
+ ////////////////////////////////////////////////////////////////////////////
+
+ template <typename MemPtr, typename Object>
+ typename enable_if<
+ is_member_object_pointer<MemPtr>
+ , typename make_mem_obj_ptr<Object, MemPtr>::type const
+ >::type
+ bind( MemPtr ptr, Object const& obj)
+ {
+ return make_mem_obj_ptr<Object, MemPtr>()(obj, ptr);
+ }
+
+}}
+
+#endif

Added: sandbox/SOC/2010/phoenix3/boost/phoenix/core/mem_obj_ptr.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/mem_obj_ptr.hpp 2010-06-17 18:13:58 EDT (Thu, 17 Jun 2010)
@@ -0,0 +1,133 @@
+/*==============================================================================
+ Copyright (c) 2005-2010 Joel de Guzman
+ Copyright (c) 2010 Thomas Heller
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef PHOENIX_CORE_MEM_OBJ_PTR_HPP
+#define PHOENIX_CORE_MEM_OBJ_PTR_HPP
+
+#include <boost/phoenix/core/compose.hpp>
+#include <boost/phoenix/core/meta_grammar.hpp>
+#include <boost/type_traits/is_const.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+
+namespace boost { namespace phoenix
+{
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // mem_obj_ptr
+ //
+ // Function to evaluate member object pointers
+ // To be used in bind and operator->*
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ namespace meta
+ {
+ template <typename T>
+ struct member_type;
+
+ template <typename Class, typename MemberType>
+ struct member_type<MemberType (Class::*)>
+ {
+ typedef MemberType type;
+ };
+
+ template <typename Class, typename MemberType>
+ struct member_type<MemberType (Class::* &)>
+ {
+ typedef MemberType type;
+ };
+
+ template <typename Class, typename MemberType>
+ struct member_type<MemberType (Class::* const&)>
+ {
+ typedef MemberType type;
+ };
+
+ template <typename T>
+ struct object_type;
+
+ template <typename T>
+ struct object_type<T*>
+ {
+ typedef T type;
+ };
+
+ /*
+ template <typename T>
+ struct object_type<shared_ptr<T> >
+ {
+ typedef T type;
+ };
+
+ template <typename T>
+ struct object_type<scoped_ptr<T> >
+ {
+ typedef T type;
+ };
+
+ template <typename T>
+ struct object_type<std::auto_ptr<T> >
+ {
+ typedef T type;
+ };
+ */
+ }
+
+ namespace result_of
+ {
+ template <typename Env, typename Object, typename MemPtr>
+ struct mem_obj_ptr
+ : boost::result_of<eval_grammar()>
+ {
+ typedef typename meta::object_type<
+ typename remove_const<
+ typename remove_reference<
+ typename boost::result_of<
+ eval_grammar(Object const&, Env&)>::type
+ >::type
+ >::type
+ >::type object_type;
+
+ typedef typename meta::member_type<
+ typename boost::result_of<
+ eval_grammar(MemPtr const&, Env&)>::type
+ >::type member_type;
+
+ typedef typename add_reference<
+ typename mpl::eval_if<
+ is_const<object_type>
+ , add_const<member_type>
+ , mpl::identity<member_type> >::type
+ >::type type;
+ };
+ }
+
+ struct mem_obj_ptr
+ {
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Env, typename Object, typename MemPtr>
+ struct result<This(Env&, Object const&, MemPtr const&)>
+ : result_of::mem_obj_ptr<Env, Object, MemPtr>
+ {};
+
+ template <typename Env, typename Object, typename MemPtr>
+ typename result_of::mem_obj_ptr<Env, Object, MemPtr>::type
+ operator()(Env& env, Object const& obj, MemPtr const& ptr) const
+ {
+ return get_pointer(eval(obj, env))->*eval(ptr, env);
+ }
+ };
+
+ template <typename Object, typename MemPtr>
+ struct make_mem_obj_ptr : compose<mem_obj_ptr, Object, MemPtr> {};
+
+
+}}
+
+#endif

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/reference.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/reference.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/reference.hpp 2010-06-17 18:13:58 EDT (Thu, 17 Jun 2010)
@@ -53,14 +53,14 @@
     struct make_reference : compose<reference, T&> {};
 
     template <typename T>
- typename make_reference<T>::type
+ typename make_reference<T>::type const
     ref(T& t)
     {
         return make_reference<T>()(t);
     }
 
     template <typename T>
- typename make_reference<T const>::type
+ typename make_reference<T const>::type const
     cref(T& t)
     {
         return make_reference<T const>()(t);

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp 2010-06-17 18:13:58 EDT (Thu, 17 Jun 2010)
@@ -16,10 +16,21 @@
 namespace boost { namespace phoenix
 {
     ////////////////////////////////////////////////////////////////////////////
- // Values
+ //
+ // values
+ //
+ // function for evaluating values, e.g. val(123)
+ //
     ////////////////////////////////////////////////////////////////////////////
 
- // function for evaluating values, e.g. val( 123 )
+ namespace result_of
+ {
+ template <typename Env, typename T>
+ struct value
+ : boost::result_of<eval_grammar(T)>
+ {};
+ }
+
     struct value
     {
         template<typename T>
@@ -30,23 +41,26 @@
         struct result;
 
         template<typename This, typename Env, typename T>
- struct result<This(Env &,T &)>
- : boost::result_of<eval_grammar(T)>
+ struct result<This(Env&,T const&)>
+ : result_of::value<Env, T>
         {};
 
         template<typename Env, typename T>
- typename boost::result_of<eval_grammar(T)>::type
- operator()(Env & env, T const & t)
+ typename result_of::value<Env, T>::type
+ operator()(Env& env, T const& t)
         {
             return eval(t);
         }
     };
 
+ template <typename T>
+ struct make_value : compose<value, T> {};
+
     template<typename T>
- typename value::compose<T>::result_type
+ typename make_value<T>::type const
     val(T const & t )
     {
- return value::compose<T>()(t);
+ return make_value<T>()(t);
     }
 
 }}

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/operator/member.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/operator/member.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/operator/member.hpp 2010-06-17 18:13:58 EDT (Thu, 17 Jun 2010)
@@ -11,26 +11,31 @@
 #ifndef PHOENIX_OPERATOR_MEMBER_HPP
 #define PHOENIX_OPERATOR_MEMBER_HPP
 
+#include <boost/get_pointer.hpp>
 #include <boost/phoenix/core/actor.hpp>
+#include <boost/phoenix/core/compose.hpp>
 #include <boost/phoenix/core/domain.hpp>
+#include <boost/phoenix/core/mem_obj_ptr.hpp>
 #include <boost/phoenix/support/iterate.hpp>
 #include <boost/proto/make_expr.hpp>
 #include <boost/proto/tags.hpp>
 #include <boost/type_traits/is_member_function_pointer.hpp>
+#include <boost/type_traits/is_member_object_pointer.hpp>
 
 namespace boost { namespace phoenix
 {
     namespace detail
     {
+
         namespace result_of
         {
             template <typename Object, typename MemPtr,
                 PHOENIX_typename_A_void(PHOENIX_MEMBER_LIMIT)
                 , typename Dummy = void>
- struct mem_ptr;
+ struct mem_fun_ptr;
 
             template <typename Object, typename MemPtr>
- struct mem_ptr<Object, MemPtr>
+ struct mem_fun_ptr<Object, MemPtr>
                 : proto::result_of::make_expr<
                       proto::tag::function
                     , phoenix_domain
@@ -49,14 +54,14 @@
         }
 
         template <typename Object, typename MemPtr>
- struct mem_ptr
+ struct mem_fun_ptr
         {
- mem_ptr(Object const& obj, MemPtr ptr)
+ mem_fun_ptr(Object const& obj, MemPtr ptr)
               : obj(obj)
               , ptr(ptr)
             {}
 
- typename result_of::mem_ptr<Object, MemPtr>::type const
+ typename result_of::mem_fun_ptr<Object, MemPtr>::type const
             operator()() const
             {
                 return proto::make_expr<
@@ -75,23 +80,41 @@
             MemPtr ptr;
 
         };
+
     }
 
     ////////////////////////////////////////////////////////////////////////////
     //
     // This operator overload is preferred to Proto's when the second parameter
     // is a member function pointer. If it is a member object pointer, Proto's
- // default handling will do the right thing.
+ // default handling could do the right thing, if there wasn't MSVC.
     //
     ////////////////////////////////////////////////////////////////////////////
     template <typename Object, typename MemPtr>
     typename enable_if<
         is_member_function_pointer<MemPtr>
- , detail::mem_ptr<actor<Object>, MemPtr> const
+ , detail::mem_fun_ptr<actor<Object>, MemPtr> const
+ >::type
+ operator->*(actor<Object> const& obj, MemPtr ptr)
+ {
+ return detail::mem_fun_ptr<actor<Object>, MemPtr>(obj, ptr);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // This operator overload is preferred to Proto's when the second parameter
+ // is a member object pointer. If it is a member object pointer, Proto's
+ // default handling could do the right thing, if there wasn't MSVC.
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename Object, typename MemPtr>
+ typename enable_if<
+ is_member_object_pointer<MemPtr>
+ , typename make_mem_obj_ptr<actor<Object>, MemPtr>::type const
>::type
     operator->*(actor<Object> const& obj, MemPtr ptr)
     {
- return detail::mem_ptr<actor<Object>, MemPtr>(obj, ptr);
+ return make_mem_obj_ptr<actor<Object>, MemPtr>()(obj, ptr);
     }
 
 }}
@@ -103,7 +126,7 @@
 #if BOOST_PP_ITERATION_FLAGS() == PHOENIX_ITERATE_RESULT_OF
 
             template <typename Object, typename MemPtr, PHOENIX_typename_A>
- struct mem_ptr<Object, MemPtr, PHOENIX_A>
+ struct mem_fun_ptr<Object, MemPtr, PHOENIX_A>
                 : proto::result_of::make_expr<
                       proto::tag::function
                     , phoenix_domain
@@ -115,7 +138,7 @@
 #elif BOOST_PP_ITERATION_FLAGS() == PHOENIX_ITERATE_OPERATOR
 
             template <PHOENIX_typename_A>
- typename result_of::mem_ptr<Object, MemPtr, PHOENIX_A>::type const
+ typename result_of::mem_fun_ptr<Object, MemPtr, PHOENIX_A>::type const
             operator()(PHOENIX_A_const_ref_a) const
             {
                 return proto::make_expr<

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile 2010-06-17 18:13:58 EDT (Thu, 17 Jun 2010)
@@ -52,7 +52,7 @@
     [ run bind/bind_function_tests.cpp ]
     [ run bind/bind_function_object_tests.cpp ]
     [ run bind/bind_member_function_tests.cpp ]
-# [ run bind/bind_member_variable_tests.cpp ]
+ [ run bind/bind_member_variable_tests.cpp ]
     ;
     
 test-suite phoenix_statement :

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/operator/member.cpp 2010-06-17 18:13:58 EDT (Thu, 17 Jun 2010)
@@ -58,6 +58,7 @@
     BOOST_TEST((arg1->*&Test::func)(5)(ptr) == 5);
     BOOST_TEST((arg1->*&Test::kunc)()(ptr));
 
+ /*
     shared_ptr<Test> sptr(new Test(test));
 
     BOOST_TEST((arg1->*&Test::value)(sptr) == 2);
@@ -87,6 +88,7 @@
 
     BOOST_TEST((arg1->*&Test::value)(captr) == 2);
     BOOST_TEST((arg1->*&Test::func)(11)(captr) == 11);
+ */
 
     return 0;
 }


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