is_member_func_test.cpp 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // (C) Copyright John Maddock 2000.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifdef TEST_STD
  6. # include <type_traits>
  7. #else
  8. # include <boost/type_traits/is_member_function_pointer.hpp>
  9. #endif
  10. #include "test.hpp"
  11. #include "check_integral_constant.hpp"
  12. #if defined(BOOST_GCC) && (BOOST_GCC >= 70000)
  13. #pragma GCC diagnostic ignored "-Wnoexcept-type"
  14. #endif
  15. #ifdef BOOST_TT_HAS_ASCCURATE_IS_FUNCTION
  16. struct tricky_members
  17. {
  18. void noexcept_proc()noexcept
  19. {}
  20. void const_ref_proc()const &
  21. {}
  22. void rvalue_proc()&&
  23. {}
  24. };
  25. template <class T>
  26. void test_tricky(T)
  27. {
  28. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<T>::value, true);
  29. }
  30. #endif
  31. TT_TEST_BEGIN(is_member_function_pointer)
  32. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<f1>::value, false);
  33. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<f2>::value, false);
  34. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<f3>::value, false);
  35. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<void*>::value, false);
  36. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<mf1>::value, true);
  37. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<mf2>::value, true);
  38. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<mf3>::value, true);
  39. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<mf4>::value, true);
  40. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<cmf>::value, true);
  41. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<mp>::value, false);
  42. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<void>::value, false);
  43. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<test_abc1>::value, false);
  44. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<foo0_t>::value, false);
  45. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<int&>::value, false);
  46. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const int&>::value, false);
  47. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const int[2] >::value, false);
  48. #if defined(__cpp_noexcept_function_type) && !defined(BOOST_TT_NO_NOEXCEPT_SEPARATE_TYPE)
  49. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<mf5>::value, true);
  50. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<mf6>::value, true);
  51. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<mf7>::value, true);
  52. #endif
  53. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<mf8>::value, true);
  54. #ifndef __IBMCPP__
  55. // this test may not be strictly legal:
  56. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const int[] >::value, false);
  57. #endif
  58. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<void>::value, false);
  59. #ifdef BOOST_TT_TEST_MS_FUNC_SIGS
  60. typedef void (__stdcall test_abc1::*scall_proc)();
  61. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<scall_proc>::value, true);
  62. #ifndef __CLR_VER
  63. typedef void (__fastcall test_abc1::*fcall_proc)(int);
  64. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<fcall_proc>::value, true);
  65. #endif
  66. typedef void (__cdecl test_abc1::*ccall_proc)(int, long, double);
  67. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<ccall_proc>::value, true);
  68. #if (_MSC_VER >= 1800) && !defined(__CLR_VER) && (defined(_M_IX86_FP) && (_M_IX86_FP >= 2) || defined(_M_X64))
  69. typedef void(__vectorcall test_abc1::*vcall_proc)(int, long, double, double, double, double);
  70. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<vcall_proc>::value, true);
  71. #endif
  72. typedef void(__thiscall test_abc1::*tcall_proc)(int, long, double, double, double, double);
  73. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<tcall_proc>::value, true);
  74. #endif
  75. #ifdef BOOST_TT_HAS_ASCCURATE_IS_FUNCTION
  76. test_tricky(&tricky_members::const_ref_proc);
  77. #ifndef BOOST_TT_NO_NOEXCEPT_SEPARATE_TYPE
  78. test_tricky(&tricky_members::noexcept_proc);
  79. #endif
  80. test_tricky(&tricky_members::rvalue_proc);
  81. #endif
  82. TT_TEST_END