16 #ifndef ATHCONTAINERS_TOOLS_DVLCAST_H
17 #define ATHCONTAINERS_TOOLS_DVLCAST_H
49 template <
class DVL,
bool has_virtual=DVL::has_virtual>
struct DVLCast {};
58 typedef typename DVL::base_value_type
T;
68 return static_cast<T*
> (
b);
79 return static_cast<const T*
> (
b);
90 typedef typename DVL::base_value_type
T;
99 T* ret =
dynamic_cast<T*
> (
b);
100 int offs =
reinterpret_cast<char*
>(ret) -
reinterpret_cast<char*
>(
b);
118 if (
typeid(*
b) ==
typeid(
T)) {
119 static const ptrdiff_t offs = find_offset (
b);
120 return reinterpret_cast<T*
> (
reinterpret_cast<char*
>(
b) + offs);
123 return dynamic_cast<T*
> (
b);
137 if (
typeid(*
b) ==
typeid(
T)) {
138 static ptrdiff_t offs = LONG_MAX;
139 if (offs == LONG_MAX) {
140 T* ret =
dynamic_cast<const T*
> (
b);
141 offs =
reinterpret_cast<char*
>(ret) -
reinterpret_cast<char*
>(
b);
144 return reinterpret_cast<const T*
> (
reinterpret_cast<char*
>(
b) + offs);
147 return dynamic_cast<const T*
> (
b);
155 #endif // not ATHCONTAINERS_TOOLS_DVLCAST_H