1 // 2 // mem_fn_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/mem_fn.hpp> 12 #include <boost/ref.hpp> 13 #include <boost/detail/lightweight_test.hpp> 14 15 struct X 16 { fX17 int f() 18 { 19 return 1; 20 } 21 gX22 int g() const 23 { 24 return 2; 25 } 26 }; 27 main()28int main() 29 { 30 X x; 31 32 BOOST_TEST( boost::mem_fn( &X::f )( boost::ref( x ) ) == 1 ); 33 BOOST_TEST( boost::mem_fn( &X::g )( boost::cref( x ) ) == 2 ); 34 35 return boost::report_errors(); 36 } 37