16#ifndef ATHCONTAINERS_TOOLS_DVLCAST_H
17#define ATHCONTAINERS_TOOLS_DVLCAST_H
49template <
class DVL,
bool has_virtual=DVL::has_virtual>
struct DVLCast {};
58 typedef typename DVL::base_value_type
T;
68 return static_cast<T*
> (b);
77 static const T*
cast (
const U* 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)) {
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);
static T * cast(U *b)
Cast b to a T*.
static const T * cast(const U *b)
Cast b to a const T*.
static T * cast(U *b)
Cast b to a T*.
static const T * cast(const U *b)
Cast b to a const T*.
static int find_offset(U *b)
Find the offset of T within U.
casting operations for DataVector/DataList.