/extlibs/Boost/include/boost/type_traits/is_polymorphic.hpp

https://bitbucket.org/hugoruscitti/pilascpp · C++ Header · 114 lines · 85 code · 18 blank · 11 comment · 6 complexity · 2e1f87f58eb136adb80c38fc419215ed MD5 · raw file

  1. // (C) Copyright John Maddock 2000.
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. //
  6. // See http://www.boost.org/libs/type_traits for most recent version including documentation.
  7. #ifndef BOOST_TT_IS_POLYMORPHIC_HPP
  8. #define BOOST_TT_IS_POLYMORPHIC_HPP
  9. #include <boost/type_traits/intrinsics.hpp>
  10. #ifndef BOOST_IS_POLYMORPHIC
  11. #include <boost/type_traits/is_class.hpp>
  12. #include <boost/type_traits/remove_cv.hpp>
  13. #endif
  14. // should be the last #include
  15. #include <boost/type_traits/detail/bool_trait_def.hpp>
  16. #include <boost/detail/workaround.hpp>
  17. namespace boost{
  18. #ifndef BOOST_IS_POLYMORPHIC
  19. namespace detail{
  20. template <class T>
  21. struct is_polymorphic_imp1
  22. {
  23. # if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) // CWPro7 should return false always.
  24. typedef char d1, (&d2)[2];
  25. # else
  26. typedef typename remove_cv<T>::type ncvT;
  27. struct d1 : public ncvT
  28. {
  29. d1();
  30. # if !defined(__GNUC__) // this raises warnings with some classes, and buys nothing with GCC
  31. ~d1()throw();
  32. # endif
  33. char padding[256];
  34. private:
  35. // keep some picky compilers happy:
  36. d1(const d1&);
  37. d1& operator=(const d1&);
  38. };
  39. struct d2 : public ncvT
  40. {
  41. d2();
  42. virtual ~d2()throw();
  43. # if !defined(BOOST_MSVC) && !defined(__ICL)
  44. // for some reason this messes up VC++ when T has virtual bases,
  45. // probably likewise for compilers that use the same ABI:
  46. struct unique{};
  47. virtual void unique_name_to_boost5487629(unique*);
  48. # endif
  49. char padding[256];
  50. private:
  51. // keep some picky compilers happy:
  52. d2(const d2&);
  53. d2& operator=(const d2&);
  54. };
  55. # endif
  56. BOOST_STATIC_CONSTANT(bool, value = (sizeof(d2) == sizeof(d1)));
  57. };
  58. template <class T>
  59. struct is_polymorphic_imp2
  60. {
  61. BOOST_STATIC_CONSTANT(bool, value = false);
  62. };
  63. template <bool is_class>
  64. struct is_polymorphic_selector
  65. {
  66. template <class T>
  67. struct rebind
  68. {
  69. typedef is_polymorphic_imp2<T> type;
  70. };
  71. };
  72. template <>
  73. struct is_polymorphic_selector<true>
  74. {
  75. template <class T>
  76. struct rebind
  77. {
  78. typedef is_polymorphic_imp1<T> type;
  79. };
  80. };
  81. template <class T>
  82. struct is_polymorphic_imp
  83. {
  84. typedef is_polymorphic_selector< ::boost::is_class<T>::value> selector;
  85. typedef typename selector::template rebind<T> binder;
  86. typedef typename binder::type imp_type;
  87. BOOST_STATIC_CONSTANT(bool, value = imp_type::value);
  88. };
  89. } // namespace detail
  90. BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,::boost::detail::is_polymorphic_imp<T>::value)
  91. #else // BOOST_IS_POLYMORPHIC
  92. BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,BOOST_IS_POLYMORPHIC(T))
  93. #endif
  94. } // namespace boost
  95. #include <boost/type_traits/detail/bool_trait_undef.hpp>
  96. #endif