mem_fn_ref_test.cpp 648 B

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