is_function_cxx_03.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Copyright 2000 John Maddock (john@johnmaddock.co.uk)
  2. // Copyright 2002 Aleksey Gurtovoy (agurtovoy@meta-comm.com)
  3. //
  4. // Use, modification and distribution are subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt).
  7. //
  8. // See http://www.boost.org/libs/type_traits for most recent version including documentation.
  9. #ifndef BOOST_TT_IS_FUNCTION_CXX_03_HPP_INCLUDED
  10. #define BOOST_TT_IS_FUNCTION_CXX_03_HPP_INCLUDED
  11. #include <boost/type_traits/is_reference.hpp>
  12. #if !defined(BOOST_TT_TEST_MS_FUNC_SIGS)
  13. # include <boost/type_traits/detail/is_function_ptr_helper.hpp>
  14. #else
  15. # include <boost/type_traits/detail/is_function_ptr_tester.hpp>
  16. # include <boost/type_traits/detail/yes_no_type.hpp>
  17. #endif
  18. // is a type a function?
  19. // Please note that this implementation is unnecessarily complex:
  20. // we could just use !is_convertible<T*, const volatile void*>::value,
  21. // except that some compilers erroneously allow conversions from
  22. // function pointers to void*.
  23. namespace boost {
  24. #if !defined( __CODEGEARC__ )
  25. namespace detail {
  26. #if !defined(BOOST_TT_TEST_MS_FUNC_SIGS)
  27. template<bool is_ref = true>
  28. struct is_function_chooser
  29. {
  30. template< typename T > struct result_
  31. : public false_type {};
  32. };
  33. template <>
  34. struct is_function_chooser<false>
  35. {
  36. template< typename T > struct result_
  37. : public ::boost::type_traits::is_function_ptr_helper<T*> {};
  38. };
  39. template <typename T>
  40. struct is_function_impl
  41. : public is_function_chooser< ::boost::is_reference<T>::value >
  42. ::BOOST_NESTED_TEMPLATE result_<T>
  43. {
  44. };
  45. #else
  46. template <typename T>
  47. struct is_function_impl
  48. {
  49. #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
  50. #pragma warning(push)
  51. #pragma warning(disable:6334)
  52. #endif
  53. static T* t;
  54. BOOST_STATIC_CONSTANT(
  55. bool, value = sizeof(::boost::type_traits::is_function_ptr_tester(t))
  56. == sizeof(::boost::type_traits::yes_type)
  57. );
  58. #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
  59. #pragma warning(pop)
  60. #endif
  61. };
  62. template <typename T>
  63. struct is_function_impl<T&> : public false_type
  64. {};
  65. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  66. template <typename T>
  67. struct is_function_impl<T&&> : public false_type
  68. {};
  69. #endif
  70. #endif
  71. } // namespace detail
  72. #endif // !defined( __CODEGEARC__ )
  73. #if defined( __CODEGEARC__ )
  74. template <class T> struct is_function : integral_constant<bool, __is_function(T)> {};
  75. #else
  76. template <class T> struct is_function : integral_constant<bool, ::boost::detail::is_function_impl<T>::value> {};
  77. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  78. template <class T> struct is_function<T&&> : public false_type {};
  79. #endif
  80. #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1600)
  81. template <class T> struct is_function<T&> : public false_type {};
  82. #endif
  83. #endif
  84. } // namespace boost
  85. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, <= 1700)
  86. #include <boost/type_traits/detail/is_function_msvc10_fix.hpp>
  87. #endif
  88. #endif // BOOST_TT_IS_FUNCTION_CXX_03_HPP_INCLUDED