bind_stdcall_test.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #include <boost/config.hpp>
  2. #ifndef BOOST_MSVC
  3. int main()
  4. {
  5. }
  6. #else
  7. #include <boost/config.hpp>
  8. #if defined(BOOST_MSVC)
  9. #pragma warning(disable: 4786) // identifier truncated in debug info
  10. #pragma warning(disable: 4710) // function not inlined
  11. #pragma warning(disable: 4711) // function selected for automatic inline expansion
  12. #pragma warning(disable: 4514) // unreferenced inline removed
  13. #endif
  14. //
  15. // bind_stdcall_test.cpp - test for bind.hpp + __stdcall (free functions)
  16. //
  17. // Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
  18. //
  19. // Distributed under the Boost Software License, Version 1.0. (See
  20. // accompanying file LICENSE_1_0.txt or copy at
  21. // http://www.boost.org/LICENSE_1_0.txt)
  22. //
  23. #define BOOST_BIND_ENABLE_STDCALL
  24. #include <boost/bind.hpp>
  25. #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
  26. #pragma warning(push, 3)
  27. #endif
  28. #include <iostream>
  29. #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
  30. #pragma warning(pop)
  31. #endif
  32. #include <boost/detail/lightweight_test.hpp>
  33. //
  34. long __stdcall f_0()
  35. {
  36. return 17041L;
  37. }
  38. long __stdcall f_1(long a)
  39. {
  40. return a;
  41. }
  42. long __stdcall f_2(long a, long b)
  43. {
  44. return a + 10 * b;
  45. }
  46. long __stdcall f_3(long a, long b, long c)
  47. {
  48. return a + 10 * b + 100 * c;
  49. }
  50. long __stdcall f_4(long a, long b, long c, long d)
  51. {
  52. return a + 10 * b + 100 * c + 1000 * d;
  53. }
  54. long __stdcall f_5(long a, long b, long c, long d, long e)
  55. {
  56. return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
  57. }
  58. long __stdcall f_6(long a, long b, long c, long d, long e, long f)
  59. {
  60. return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
  61. }
  62. long __stdcall f_7(long a, long b, long c, long d, long e, long f, long g)
  63. {
  64. return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
  65. }
  66. long __stdcall f_8(long a, long b, long c, long d, long e, long f, long g, long h)
  67. {
  68. return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
  69. }
  70. long __stdcall f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
  71. {
  72. return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
  73. }
  74. void function_test()
  75. {
  76. using namespace boost;
  77. int const i = 1;
  78. BOOST_TEST( bind(f_0)(i) == 17041L );
  79. BOOST_TEST( bind(f_1, _1)(i) == 1L );
  80. BOOST_TEST( bind(f_2, _1, 2)(i) == 21L );
  81. BOOST_TEST( bind(f_3, _1, 2, 3)(i) == 321L );
  82. BOOST_TEST( bind(f_4, _1, 2, 3, 4)(i) == 4321L );
  83. BOOST_TEST( bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L );
  84. BOOST_TEST( bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L );
  85. BOOST_TEST( bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L );
  86. BOOST_TEST( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L );
  87. BOOST_TEST( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L );
  88. }
  89. int main()
  90. {
  91. function_test();
  92. return boost::report_errors();
  93. }
  94. #endif