result.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/python/detail/result.hpp>
  6. #include <boost/type.hpp>
  7. #include <functional>
  8. using boost::python::detail::result;
  9. using boost::type;
  10. void expect_int(type<int>*) {}
  11. void expect_string(type<char*>*) {}
  12. struct X {};
  13. int main()
  14. {
  15. // Test the usage which works for functions, member functions, and data members
  16. expect_int(
  17. result((int(*)())0)
  18. );
  19. expect_int(
  20. result((int(*)(char))0)
  21. );
  22. expect_int(
  23. result((int(X::*)())0)
  24. );
  25. expect_int(
  26. result((int(X::*)(char))0)
  27. );
  28. expect_int(
  29. result((int(X::*))0)
  30. );
  31. expect_string(
  32. result((char*(*)())0)
  33. );
  34. expect_string(
  35. result((char*(*)(char))0)
  36. );
  37. expect_string(
  38. result((char*(X::*)())0)
  39. );
  40. expect_string(
  41. result((char*(X::*)(char))0)
  42. );
  43. expect_string(
  44. result((char*(X::*))0)
  45. );
  46. // Show that we can use the general version that works for
  47. // AdaptableFunctions
  48. expect_int(
  49. result((int(*)())0,0)
  50. );
  51. expect_int(
  52. result((int(*)(char))0,0)
  53. );
  54. expect_int(
  55. result((int(X::*)())0,0)
  56. );
  57. expect_int(
  58. result((int(X::*)(char))0,0)
  59. );
  60. expect_int(
  61. result((int(X::*))0,0)
  62. );
  63. expect_int(
  64. result(std::plus<int>(),0)
  65. );
  66. expect_string(
  67. result((char*(*)())0,0)
  68. );
  69. expect_string(
  70. result((char*(*)(char))0,0)
  71. );
  72. expect_string(
  73. result((char*(X::*)())0,0)
  74. );
  75. expect_string(
  76. result((char*(X::*)(char))0,0)
  77. );
  78. expect_string(
  79. result((char*(X::*))0,0)
  80. );
  81. expect_string(
  82. result(std::plus<char*>(),0)
  83. );
  84. return 0;
  85. }