Brian Silverman | ce4aa8d | 2018-08-04 23:36:03 -0700 | [diff] [blame^] | 1 | // |
| 2 | // bind_ref_test.cpp - reference_wrapper |
| 3 | // |
| 4 | // Copyright (c) 2009 Peter Dimov |
| 5 | // |
| 6 | // Distributed under the Boost Software License, Version 1.0. |
| 7 | // See accompanying file LICENSE_1_0.txt or copy at |
| 8 | // http://www.boost.org/LICENSE_1_0.txt |
| 9 | // |
| 10 | |
| 11 | #include <boost/bind.hpp> |
| 12 | #include <boost/ref.hpp> |
| 13 | #include <boost/detail/lightweight_test.hpp> |
| 14 | |
| 15 | struct X |
| 16 | { |
| 17 | int f( int x ) |
| 18 | { |
| 19 | return x; |
| 20 | } |
| 21 | |
| 22 | int g( int x ) const |
| 23 | { |
| 24 | return -x; |
| 25 | } |
| 26 | }; |
| 27 | |
| 28 | int main() |
| 29 | { |
| 30 | X x; |
| 31 | |
| 32 | BOOST_TEST( boost::bind( &X::f, _1, 1 )( boost::ref( x ) ) == 1 ); |
| 33 | BOOST_TEST( boost::bind( &X::g, _1, 2 )( boost::cref( x ) ) == -2 ); |
| 34 | |
| 35 | return boost::report_errors(); |
| 36 | } |