bind_ref_test.cpp 961 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*==============================================================================
  2. Copyright (c) 2009 Peter Dimov
  3. Copyright (c) 2005-2010 Joel de Guzman
  4. Copyright (c) 2010 Thomas Heller
  5. Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. ==============================================================================*/
  8. #include <boost/phoenix/core.hpp>
  9. #include <boost/phoenix/bind.hpp>
  10. #include <boost/ref.hpp>
  11. #include <boost/detail/lightweight_test.hpp>
  12. struct X
  13. {
  14. int f( int x )
  15. {
  16. return x;
  17. }
  18. int g( int x ) const
  19. {
  20. return -x;
  21. }
  22. };
  23. int main()
  24. {
  25. using boost::phoenix::bind;
  26. using boost::phoenix::placeholders::_1;
  27. X x;
  28. BOOST_TEST( bind( &X::f, _1, 1 )( boost::ref( x ) ) == 1 );
  29. BOOST_TEST( bind( &X::g, _1, 2 )( boost::cref( x ) ) == -2 );
  30. return boost::report_errors();
  31. }