31 #ifndef __FASTJET_INTERNAL_IS_BASE_HH__
32 #define __FASTJET_INTERNAL_IS_BASE_HH__
34 #include "fastjet/internal/numconsts.hh"
36 FASTJET_BEGIN_NAMESPACE
62 template<
typename T, T _t>
64 static const T value = _t;
66 typedef integral_type<T,_t> type;
70 template<
typename T, T _t>
71 const T integral_type<T, _t>::value;
81 typedef char (&__yes_type)[1];
82 typedef char (&__no_type) [2];
106 template<
typename B,
typename D>
107 struct __inheritance_helper{
108 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310)) // MSVC 7.1
109 template <
typename T>
110 static __yes_type check_sig(D
const volatile *, T);
112 static __yes_type check_sig(D
const volatile *,
long);
114 static __no_type check_sig(B
const volatile *,
int);
128 template<
typename B,
typename D>
129 struct IsBaseAndDerived{
130 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000))
131 #pragma warning(push)
132 #pragma warning(disable:6334)
144 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310))
145 operator B
const volatile *()
const;
147 operator B
const volatile *
const&()
const;
149 operator D
const volatile *();
153 static const bool value = ((
sizeof(B)!=0) &&
155 (
sizeof(__inheritance_helper<B,D>::check_sig(Host(), 0)) ==
sizeof(__yes_type)));
157 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000))
165 template<
class B,
class D>
167 return IsBaseAndDerived<B,D>::value ? (B*)(d) : 0;
171 FASTJET_END_NAMESPACE
174 #endif // __IS_BASE_OF_HH__
integral_type< bool, true > true_type
the bool 'true' value promoted to a type
B * cast_if_derived(D *d)
a little helper that returns a pointer to d of type B* if D is derived from B and NULL otherwise ...
integral_type< bool, false > false_type
the bool 'false' value promoted to a type