PageRenderTime 17ms CodeModel.GetById 11ms app.highlight 5ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  8#ifndef BOOST_TT_IS_POLYMORPHIC_HPP
  9#define BOOST_TT_IS_POLYMORPHIC_HPP
 10
 11#include <boost/type_traits/intrinsics.hpp>
 12#ifndef BOOST_IS_POLYMORPHIC
 13#include <boost/type_traits/is_class.hpp>
 14#include <boost/type_traits/remove_cv.hpp>
 15#endif
 16// should be the last #include
 17#include <boost/type_traits/detail/bool_trait_def.hpp>
 18#include <boost/detail/workaround.hpp>
 19
 20namespace boost{
 21
 22#ifndef BOOST_IS_POLYMORPHIC
 23
 24namespace detail{
 25
 26template <class T>
 27struct is_polymorphic_imp1
 28{
 29# if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) // CWPro7 should return false always.
 30    typedef char d1, (&d2)[2];
 31# else 
 32   typedef typename remove_cv<T>::type ncvT;
 33   struct d1 : public ncvT
 34   {
 35      d1();
 36#  if !defined(__GNUC__) // this raises warnings with some classes, and buys nothing with GCC
 37      ~d1()throw();
 38#  endif 
 39      char padding[256];
 40   private:
 41      // keep some picky compilers happy:
 42      d1(const d1&);
 43      d1& operator=(const d1&);
 44   };
 45   struct d2 : public ncvT
 46   {
 47      d2();
 48      virtual ~d2()throw();
 49#  if !defined(BOOST_MSVC) && !defined(__ICL)
 50      // for some reason this messes up VC++ when T has virtual bases,
 51      // probably likewise for compilers that use the same ABI:
 52      struct unique{};
 53      virtual void unique_name_to_boost5487629(unique*);
 54#  endif
 55      char padding[256];
 56   private:
 57      // keep some picky compilers happy:
 58      d2(const d2&);
 59      d2& operator=(const d2&);
 60   };
 61# endif 
 62   BOOST_STATIC_CONSTANT(bool, value = (sizeof(d2) == sizeof(d1)));
 63};
 64
 65template <class T>
 66struct is_polymorphic_imp2
 67{
 68   BOOST_STATIC_CONSTANT(bool, value = false);
 69};
 70
 71template <bool is_class>
 72struct is_polymorphic_selector
 73{
 74   template <class T>
 75   struct rebind
 76   {
 77      typedef is_polymorphic_imp2<T> type;
 78   };
 79};
 80
 81template <>
 82struct is_polymorphic_selector<true>
 83{
 84   template <class T>
 85   struct rebind
 86   {
 87      typedef is_polymorphic_imp1<T> type;
 88   };
 89};
 90
 91template <class T>
 92struct is_polymorphic_imp
 93{
 94   typedef is_polymorphic_selector< ::boost::is_class<T>::value> selector;
 95   typedef typename selector::template rebind<T> binder;
 96   typedef typename binder::type imp_type;
 97   BOOST_STATIC_CONSTANT(bool, value = imp_type::value);
 98};
 99
100} // namespace detail
101
102BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,::boost::detail::is_polymorphic_imp<T>::value)
103
104#else // BOOST_IS_POLYMORPHIC
105
106BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,BOOST_IS_POLYMORPHIC(T))
107
108#endif
109
110} // namespace boost
111
112#include <boost/type_traits/detail/bool_trait_undef.hpp>
113
114#endif