bind_rv_sp1_test.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*==============================================================================
  2. Copyright (c) 2006 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/config.hpp>
  9. #if defined(BOOST_MSVC)
  10. #pragma warning(disable: 4786) // identifier truncated in debug info
  11. #pragma warning(disable: 4710) // function not inlined
  12. #pragma warning(disable: 4711) // function selected for automatic inline expansion
  13. #pragma warning(disable: 4514) // unreferenced inline removed
  14. #endif
  15. #include <boost/phoenix/core.hpp>
  16. #include <boost/phoenix/bind.hpp>
  17. #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
  18. #pragma warning(push, 3)
  19. #endif
  20. #include <iostream>
  21. #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
  22. #pragma warning(pop)
  23. #endif
  24. #include <boost/detail/lightweight_test.hpp>
  25. #include <boost/shared_ptr.hpp>
  26. struct X
  27. {
  28. int v_;
  29. X( int v ): v_( v )
  30. {
  31. }
  32. int f()
  33. {
  34. return v_;
  35. }
  36. };
  37. struct Y
  38. {
  39. boost::shared_ptr<X> f()
  40. {
  41. return boost::shared_ptr<X>( new X( 42 ) );
  42. }
  43. };
  44. int main()
  45. {
  46. using boost::phoenix::bind;
  47. using boost::phoenix::placeholders::_1;
  48. Y y;
  49. // Change bind_rv_sp_test.cpp to bind to _1.
  50. BOOST_TEST( bind( &X::f, _1) ( bind( &Y::f, &y )()) == 42 );
  51. return boost::report_errors();
  52. }