bind_placeholder_test.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include <boost/config.hpp>
  2. #if defined( BOOST_MSVC )
  3. #pragma warning(disable: 4786) // identifier truncated in debug info
  4. #pragma warning(disable: 4710) // function not inlined
  5. #pragma warning(disable: 4711) // function selected for automatic inline expansion
  6. #pragma warning(disable: 4514) // unreferenced inline removed
  7. #endif
  8. // bind_placeholder_test.cpp - test custom placeholders
  9. //
  10. // Copyright (c) 2006 Peter Dimov
  11. //
  12. // Distributed under the Boost Software License, Version 1.0.
  13. //
  14. // See accompanying file LICENSE_1_0.txt or copy at
  15. // http://www.boost.org/LICENSE_1_0.txt)
  16. #include <boost/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. {
  32. };
  33. namespace boost
  34. {
  35. template< int I > struct is_placeholder< custom_placeholder< I > >
  36. {
  37. enum { value = I };
  38. };
  39. } // namespace boost
  40. int main()
  41. {
  42. int const x1 = 1;
  43. int const x2 = 2;
  44. int const x3 = 3;
  45. int const x4 = 4;
  46. int const x5 = 5;
  47. int const x6 = 6;
  48. int const x7 = 7;
  49. int const x8 = 8;
  50. int const x9 = 9;
  51. custom_placeholder<1> p1;
  52. custom_placeholder<2> p2;
  53. custom_placeholder<3> p3;
  54. custom_placeholder<4> p4;
  55. custom_placeholder<5> p5;
  56. custom_placeholder<6> p6;
  57. custom_placeholder<7> p7;
  58. custom_placeholder<8> p8;
  59. custom_placeholder<9> p9;
  60. BOOST_TEST(
  61. boost::bind( f, p1, p2, p3, p4, p5, p6, p7, p8, p9 )
  62. ( x1, x2, x3, x4, x5, x6, x7, x8, x9 ) == 987654321L );
  63. return boost::report_errors();
  64. }