#define CAST(T,X,Ofs) (*(reinterpret_cast<T *>(CharP(&(X)) + Ofs)))
+/* StructAfter<T>(X) returns the struct T& that is placed after X.
+ * Works with X of variable size also. */
template<typename Type, typename TObject>
inline const Type& StructAfter(const TObject &X)
{
return * reinterpret_cast<Type*> (CharP (&X) + X.get_size());
}
-template<typename Type, typename TObject>
-inline const Type* ArrayAfter(const TObject &X)
-{
- return reinterpret_cast<const Type*> (ConstCharP (&X) + X.get_size());
-}
-template<typename Type, typename TObject>
-inline Type* ArrayAfter(TObject &X)
-{
- return reinterpret_cast<Type*> (CharP (&X) + X.get_size());
-}
-
/*
* Class features
template <typename LenType, typename Type>
struct GenericArrayOf
{
- const Type *const_array(void) const { return ArrayAfter<Type> (len); }
- Type *array(void) { return ArrayAfter<Type> (len); }
+ const Type *const_array(void) const { return &StructAfter<Type> (len); }
+ Type *array(void) { return &StructAfter<Type> (len); }
const Type *const_sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
{
template <typename Type>
struct HeadlessArrayOf
{
- const Type *const_array(void) const { return ArrayAfter<Type> (len); }
- Type *array(void) { return ArrayAfter<Type> (len); }
+ const Type *const_array(void) const { return &StructAfter<Type> (len); }
+ Type *array(void) { return &StructAfter<Type> (len); }
inline const Type& operator [] (unsigned int i) const
{