bind_placeholder_test.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*==============================================================================
  2. Copyright (c) 2005 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. long f( long a, long b, long c, long d, long e, long f, long g, long h, long i )
  27. {
  28. return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
  29. }
  30. template< int I > struct custom_placeholder
  31. : boost::mpl::int_<I>
  32. {
  33. };
  34. namespace boost
  35. {
  36. template< int I > struct is_placeholder< custom_placeholder< I > >
  37. {
  38. enum { value = I + 1};
  39. };
  40. } // namespace boost
  41. int main()
  42. {
  43. using boost::phoenix::bind;
  44. int const x1 = 1;
  45. int const x2 = 2;
  46. int const x3 = 3;
  47. int const x4 = 4;
  48. int const x5 = 5;
  49. int const x6 = 6;
  50. int const x7 = 7;
  51. int const x8 = 8;
  52. int const x9 = 9;
  53. custom_placeholder<0> p1;
  54. custom_placeholder<1> p2;
  55. custom_placeholder<2> p3;
  56. custom_placeholder<3> p4;
  57. custom_placeholder<4> p5;
  58. custom_placeholder<5> p6;
  59. custom_placeholder<6> p7;
  60. custom_placeholder<7> p8;
  61. custom_placeholder<8> p9;
  62. BOOST_TEST(
  63. bind( f, p1, p2, p3, p4, p5, p6, p7, p8, p9 )
  64. ( x1, x2, x3, x4, x5, x6, x7, x8, x9 ) == 987654321L );
  65. return boost::report_errors();
  66. }