is_function_pointer.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // (C) Copyright Tobias Schwinger
  2. //
  3. // Use modification and distribution are subject to the boost Software License,
  4. // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
  5. //------------------------------------------------------------------------------
  6. #include <boost/mpl/assert.hpp>
  7. #include <boost/function_types/is_function_pointer.hpp>
  8. namespace ft = boost::function_types;
  9. typedef void func();
  10. typedef void (*func_ptr)();
  11. typedef void (&func_ref)();
  12. class C;
  13. typedef void (C::*mem_func_ptr)();
  14. typedef void (C::*c_mem_func_ptr)() const;
  15. typedef void (C::*v_mem_func_ptr)() volatile;
  16. typedef void (C::*cv_mem_func_ptr)() const volatile;
  17. BOOST_MPL_ASSERT_NOT((
  18. ft::is_function_pointer< func >
  19. ));
  20. BOOST_MPL_ASSERT((
  21. ft::is_function_pointer< func_ptr >
  22. ));
  23. BOOST_MPL_ASSERT_NOT((
  24. ft::is_function_pointer< func_ref >
  25. ));
  26. BOOST_MPL_ASSERT_NOT((
  27. ft::is_function_pointer< mem_func_ptr >
  28. ));
  29. BOOST_MPL_ASSERT_NOT((
  30. ft::is_function_pointer< c_mem_func_ptr >
  31. ));
  32. BOOST_MPL_ASSERT_NOT((
  33. ft::is_function_pointer< v_mem_func_ptr >
  34. ));
  35. BOOST_MPL_ASSERT_NOT((
  36. ft::is_function_pointer< cv_mem_func_ptr >
  37. ));
  38. BOOST_MPL_ASSERT_NOT((
  39. ft::is_function_pointer< func_ptr* >
  40. ));
  41. BOOST_MPL_ASSERT_NOT((
  42. ft::is_function_pointer< mem_func_ptr* >
  43. ));
  44. BOOST_MPL_ASSERT_NOT((
  45. ft::is_function_pointer< C >
  46. ));
  47. BOOST_MPL_ASSERT_NOT((
  48. ft::is_function_pointer< int >
  49. ));
  50. BOOST_MPL_ASSERT_NOT((
  51. ft::is_function_pointer< int* >
  52. ));
  53. BOOST_MPL_ASSERT_NOT((
  54. ft::is_function_pointer< int** >
  55. ));
  56. BOOST_MPL_ASSERT_NOT((
  57. ft::is_function_pointer< int& >
  58. ));
  59. BOOST_MPL_ASSERT_NOT((
  60. ft::is_function_pointer< int[] >
  61. ));
  62. BOOST_MPL_ASSERT_NOT((
  63. ft::is_function_pointer< int[1] >
  64. ));