|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51512 - in trunk: boost libs/bind/test
From: pdimov_at_[hidden]
Date: 2009-03-01 12:04:15
Author: pdimov
Date: 2009-03-01 12:04:14 EST (Sun, 01 Mar 2009)
New Revision: 51512
URL: http://svn.boost.org/trac/boost/changeset/51512
Log:
Refs #2128 (fixed in trunk.)
Added:
trunk/libs/bind/test/bind_ref_test.cpp (contents, props changed)
trunk/libs/bind/test/mem_fn_ref_test.cpp (contents, props changed)
Text files modified:
trunk/boost/ref.hpp | 5 +++++
trunk/libs/bind/test/Jamfile.v2 | 2 ++
2 files changed, 7 insertions(+), 0 deletions(-)
Modified: trunk/boost/ref.hpp
==============================================================================
--- trunk/boost/ref.hpp (original)
+++ trunk/boost/ref.hpp 2009-03-01 12:04:14 EST (Sun, 01 Mar 2009)
@@ -179,6 +179,11 @@
return t;
}
+template<class T> inline T* get_pointer( reference_wrapper<T> const & r )
+{
+ return r.get_pointer();
+}
+
} // namespace boost
#endif // #ifndef BOOST_REF_HPP_INCLUDED
Modified: trunk/libs/bind/test/Jamfile.v2
==============================================================================
--- trunk/libs/bind/test/Jamfile.v2 (original)
+++ trunk/libs/bind/test/Jamfile.v2 2009-03-01 12:04:14 EST (Sun, 01 Mar 2009)
@@ -39,4 +39,6 @@
[ run bind_fn2_test.cpp ]
[ run bind_mf2_test.cpp ]
[ run bind_eq2_test.cpp ]
+ [ run mem_fn_ref_test.cpp ]
+ [ run bind_ref_test.cpp ]
;
Added: trunk/libs/bind/test/bind_ref_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/bind/test/bind_ref_test.cpp 2009-03-01 12:04:14 EST (Sun, 01 Mar 2009)
@@ -0,0 +1,36 @@
+//
+// bind_ref_test.cpp - reference_wrapper
+//
+// Copyright (c) 2009 Peter Dimov
+//
+// 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
+//
+
+#include <boost/bind.hpp>
+#include <boost/ref.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct X
+{
+ int f( int x )
+ {
+ return x;
+ }
+
+ int g( int x ) const
+ {
+ return -x;
+ }
+};
+
+int main()
+{
+ X x;
+
+ BOOST_TEST( boost::bind( &X::f, _1, 1 )( boost::ref( x ) ) == 1 );
+ BOOST_TEST( boost::bind( &X::g, _1, 2 )( boost::cref( x ) ) == -2 );
+
+ return boost::report_errors();
+}
Added: trunk/libs/bind/test/mem_fn_ref_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/bind/test/mem_fn_ref_test.cpp 2009-03-01 12:04:14 EST (Sun, 01 Mar 2009)
@@ -0,0 +1,36 @@
+//
+// mem_fn_ref_test.cpp - reference_wrapper
+//
+// Copyright (c) 2009 Peter Dimov
+//
+// 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
+//
+
+#include <boost/mem_fn.hpp>
+#include <boost/ref.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct X
+{
+ int f()
+ {
+ return 1;
+ }
+
+ int g() const
+ {
+ return 2;
+ }
+};
+
+int main()
+{
+ X x;
+
+ BOOST_TEST( boost::mem_fn( &X::f )( boost::ref( x ) ) == 1 );
+ BOOST_TEST( boost::mem_fn( &X::g )( boost::cref( x ) ) == 2 );
+
+ return boost::report_errors();
+}
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