bind_rvalue_test.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. //
  26. int f( int x )
  27. {
  28. return x;
  29. }
  30. int main()
  31. {
  32. using boost::phoenix::bind;
  33. using boost::phoenix::placeholders::_1;
  34. using boost::phoenix::placeholders::_2;
  35. using boost::phoenix::placeholders::_3;
  36. using boost::phoenix::placeholders::_4;
  37. using boost::phoenix::placeholders::_5;
  38. using boost::phoenix::placeholders::_6;
  39. using boost::phoenix::placeholders::_7;
  40. using boost::phoenix::placeholders::_8;
  41. using boost::phoenix::placeholders::_9;
  42. BOOST_TEST(
  43. bind( f, _1 )
  44. ( 1 ) == 1 );
  45. BOOST_TEST(
  46. bind( f, _2 )
  47. ( 1, 2 ) == 2 );
  48. BOOST_TEST(
  49. bind( f, _3 )
  50. ( 1, 2, 3 ) == 3 );
  51. BOOST_TEST(
  52. bind( f, _4 )
  53. ( 1, 2, 3, 4 ) == 4 );
  54. BOOST_TEST(
  55. bind( f, _5 )
  56. ( 1, 2, 3, 4, 5 ) == 5 );
  57. BOOST_TEST(
  58. bind( f, _6 )
  59. ( 1, 2, 3, 4, 5, 6 ) == 6 );
  60. BOOST_TEST(
  61. bind( f, _7 )
  62. ( 1, 2, 3, 4, 5, 6, 7 ) == 7 );
  63. BOOST_TEST(
  64. bind( f, _8 )
  65. ( 1, 2, 3, 4, 5, 6, 7, 8 ) == 8 );
  66. BOOST_TEST(
  67. bind( f, _9 )
  68. ( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) == 9 );
  69. return boost::report_errors();
  70. }