$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r67640 - in trunk: boost/lambda/detail libs/lambda/test
From: steven_at_[hidden]
Date: 2011-01-03 17:31:24
Author: steven_watanabe
Date: 2011-01-03 17:31:21 EST (Mon, 03 Jan 2011)
New Revision: 67640
URL: http://svn.boost.org/trac/boost/changeset/67640
Log:
Fix return type deduction for pointers to data members.  Fixes #4962.  Fixes #4566.
Text files modified: 
   trunk/boost/lambda/detail/function_adaptors.hpp |    17 ++++++++++++-----                       
   trunk/libs/lambda/test/bind_tests_simple.cpp    |    17 +++++++++++++++++                       
   2 files changed, 29 insertions(+), 5 deletions(-)
Modified: trunk/boost/lambda/detail/function_adaptors.hpp
==============================================================================
--- trunk/boost/lambda/detail/function_adaptors.hpp	(original)
+++ trunk/boost/lambda/detail/function_adaptors.hpp	2011-01-03 17:31:21 EST (Mon, 03 Jan 2011)
@@ -16,6 +16,9 @@
 #include "boost/tuple/tuple.hpp"
 #include "boost/type_traits/same_traits.hpp"
 #include "boost/type_traits/remove_reference.hpp"
+#include "boost/type_traits/remove_cv.hpp"
+#include "boost/type_traits/add_const.hpp"
+#include "boost/type_traits/add_volatile.hpp"
 #include "boost/utility/result_of.hpp"
 
 namespace boost { 
@@ -237,22 +240,26 @@
   // the data member is accessed is const, and finally adding a reference
   template<class Args> class sig { 
     typedef typename boost::tuples::element<1, Args>::type argument_type;
+    typedef typename boost::remove_reference<
+      argument_type
+    >::type unref_type;
 
-    typedef typename detail::IF<boost::is_const<argument_type>::value,
+    typedef typename detail::IF<boost::is_const<unref_type>::value,
       typename boost::add_const<T>::type,
       T
     >::RET properly_consted_return_type;
 
-    typedef typename detail::IF<
-        boost::is_volatile<properly_consted_return_type>::value,
+    typedef typename detail::IF<boost::is_volatile<unref_type>::value,
       typename boost::add_volatile<properly_consted_return_type>::type,
       properly_consted_return_type
     >::RET properly_cvd_return_type;
 
 
   public:
-    typedef typename 
-      boost::add_reference<properly_cvd_return_type>::type type;
+    typedef typename detail::IF<boost::is_reference<argument_type>::value,
+      typename boost::add_reference<properly_cvd_return_type>::type,
+      typename boost::remove_cv<T>::type
+    >::RET type;
   };
 
   template <class RET>
Modified: trunk/libs/lambda/test/bind_tests_simple.cpp
==============================================================================
--- trunk/libs/lambda/test/bind_tests_simple.cpp	(original)
+++ trunk/libs/lambda/test/bind_tests_simple.cpp	2011-01-03 17:31:21 EST (Mon, 03 Jan 2011)
@@ -80,6 +80,23 @@
   // bind(&A::add, a, _1); 
 }
 
+struct B {
+  B(int n) : i(n) {};
+  int i;
+};
+
+void test_data_members()
+{
+  using boost::ref;
+  B b(10);
+  BOOST_CHECK(bind(&B::i, ref(b))() == 10);
+  BOOST_CHECK(bind(&B::i, b)() == 10);
+  BOOST_CHECK(bind(&B::i, _1)(b) == 10);
+  BOOST_CHECK(bind(&B::i, _1)(B(11)) == 11);
+  bind(&B::i, ref(b))() = 1;
+  BOOST_CHECK(b.i == 1);
+}
+
 int test_main(int, char *[]) {
 
   int i = 1; int j = 2; int k = 3;