29 #ifndef __FASTJET_INTERNAL_IS_BASE_HH__ 30 #define __FASTJET_INTERNAL_IS_BASE_HH__ 32 #include "fastjet/internal/numconsts.hh" 34 FASTJET_BEGIN_NAMESPACE
60 template<
typename T, T _t>
62 static const T value = _t;
64 typedef integral_type<T,_t> type;
68 template<
typename T, T _t>
69 const T integral_type<T, _t>::value;
79 typedef char (&__yes_type)[1];
80 typedef char (&__no_type) [2];
104 template<
typename B,
typename D>
105 struct __inheritance_helper{
106 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310)) // MSVC 7.1 107 template <
typename T>
108 static __yes_type check_sig(D
const volatile *, T);
110 static __yes_type check_sig(D
const volatile *,
long);
112 static __no_type check_sig(B
const volatile *,
int);
126 template<
typename B,
typename D>
127 struct IsBaseAndDerived{
128 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000)) 129 #pragma warning(push) 130 #pragma warning(disable:6334) 142 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310)) 143 operator B
const volatile *()
const;
145 operator B
const volatile *
const&()
const;
147 operator D
const volatile *();
151 static const bool value = ((
sizeof(B)!=0) &&
153 (
sizeof(__inheritance_helper<B,D>::check_sig(Host(), 0)) ==
sizeof(__yes_type)));
155 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000)) 163 template<
class B,
class D>
165 return IsBaseAndDerived<B,D>::value ? (B*)(d) : 0;
169 FASTJET_END_NAMESPACE
172 #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