bind_void_dm_test.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*==============================================================================
  2. Copyright (c) 2006 Peter Dimov
  3. Copyright (c) 2014 Agustin Berge
  4. Copyright (c) 2015 John Fletcher
  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. #include <boost/ref.hpp>
  18. #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
  19. #pragma warning(push, 3)
  20. #endif
  21. #include <iostream>
  22. #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
  23. #pragma warning(pop)
  24. #endif
  25. #include <boost/detail/lightweight_test.hpp>
  26. //
  27. struct Z
  28. {
  29. int m;
  30. };
  31. void member_data_test()
  32. {
  33. using boost::phoenix::bind;
  34. Z z = { 17041 };
  35. Z * pz = &z;
  36. bind<void>( &Z::m, _1 )( z );
  37. bind<void>( &Z::m, _1 )( pz );
  38. bind<void>( &Z::m, z )();
  39. bind<void>( &Z::m, pz )();
  40. bind<void>( &Z::m, boost::ref(z) )();
  41. Z const cz = z;
  42. Z const * pcz = &cz;
  43. bind<void>( &Z::m, _1 )( cz );
  44. bind<void>( &Z::m, _1 )( pcz );
  45. bind<void>( &Z::m, cz )();
  46. bind<void>( &Z::m, pcz )();
  47. bind<void>( &Z::m, boost::ref(cz) )();
  48. }
  49. int main()
  50. {
  51. member_data_test();
  52. return boost::report_errors();
  53. }