• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/bind.hpp>
12 #include <boost/ref.hpp>
13 #include <boost/core/lightweight_test.hpp>
14 
15 using namespace boost::placeholders;
16 
17 //
18 
19 struct X
20 {
fX21     int f( int x )
22     {
23         return x;
24     }
25 
gX26     int g( int x ) const
27     {
28         return -x;
29     }
30 };
31 
main()32 int main()
33 {
34     X x;
35 
36     BOOST_TEST( boost::bind( &X::f, _1, 1 )( boost::ref( x ) ) == 1 );
37     BOOST_TEST( boost::bind( &X::g, _1, 2 )( boost::cref( x ) ) == -2 );
38 
39     return boost::report_errors();
40 }
41