If you could make this work I would be a happy programmer :)
#include "stdafx.h"
typedef __w64 int aint;
typedef int bint;
namespace NIds
{
class CDefaultPointerHolder
{
public:
};
#define DIdsPInlineS inline
#define DIdsPInlineM inline
#define DIdsPInlineL inline
template <typename t_CPointer, typename t_CTyped>
class TCDynamicPtr
{
public:
t_CPointer m_PtrData;
DIdsPInlineS TCDynamicPtr &operator = (t_CTyped *_pSetTo)
{
return *this;
}
DIdsPInlineS bint operator == (t_CTyped *_pCompareTo)
{
return true;
}
DIdsPInlineS operator t_CTyped * () const
{
return 0;
}
DIdsPInlineS t_CTyped * operator -> () const
{
return 0;
}
};
namespace NMem
{
class CAllocator_Heap
{
public:
};
}
#define DIdsDefaultAllocator NIds::NMem::CAllocator_Heap
namespace NTree
{
template <typename t_CPointerHolder = CDefaultPointerHolder>
class TCAVLLinkAlignedData
{
public:
typedef TCDynamicPtr<t_CPointerHolder, TCAVLLinkAlignedData> CData;
};
template <typename t_CData, typename t_CKey, typename t_CLinkData, typename t_CTranslator, typename t_CCompare, typename t_CAllocator>
class TCAVLTreeParams
{
public:
typedef t_CData CData;
typedef t_CKey CKey;
typedef t_CLinkData CLinkData;
typedef t_CTranslator CTranslator;
typedef t_CCompare CCompare;
typedef t_CAllocator CAllocator;
};
template <typename t_CParamsTree>
class TCAVLTreeAggregate
{
public:
typedef typename t_CParamsTree::CData CData;
typedef typename t_CParamsTree::CKey CKey;
typedef typename t_CParamsTree::CLinkType CLinkType;
typedef typename t_CParamsTree::CLinkData CLinkData;
typedef typename CLinkData::CData CLinkCData;
typedef typename t_CParamsTree::CTranslator CTranslator;
typedef typename t_CParamsTree::CCompare CCompare;
typedef typename t_CParamsTree::CAllocator CAllocator;
int m_TreeMember;
/************************************************************************************************\ ||-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?||
|| Iterator
||______________________________________________________________________________________________||
\\************************************************************************************************/
# define DIdsTreeAvlDefaultIteratorRecursionDepth (sizeof(void *)*12)
template <aint _RecursionDepth = DIdsTreeAvlDefaultIteratorRecursionDepth>
class TIterator
{
public:
typedef typename t_CParamsTree::CData CData;
typedef typename t_CParamsTree::CKey CKey;
typedef typename t_CParamsTree::CLinkType CLinkType;
typedef typename t_CParamsTree::CLinkData CLinkData;
typedef typename CLinkData::CData CLinkCData;
typedef typename t_CParamsTree::CTranslator CTranslator;
typedef typename t_CParamsTree::CCompare CCompare;
typedef typename t_CParamsTree::CAllocator CAllocator;
int m_IteratorMember;
DIdsPInlineS TIterator(const TCAVLTreeAggregate &_Tree)
{
}
DIdsPInlineS CData *GetCurrent() const
{
return 0;
}
DIdsPInlineS operator CData *() const
{
return GetCurrent();
}
DIdsPInlineS CData * operator ->() const
{
return GetCurrent();
}
DIdsPInlineS void operator ++()
{
}
DIdsPInlineS void operator --()
{
}
};
};
template <typename t_CParams>
class TCAVLTree : public TCAVLTreeAggregate<t_CParams>
{
public:
TCAVLTree()
{
}
~TCAVLTree()
{
}
};
template <typename t_CParamsLink>
class TCAVLLinkAggregate
{
public:
class CParams : public t_CParamsLink
{
public:
typedef TCAVLLinkAggregate CLinkType;
};
};
template <typename t_CParamsLink>
class TCAVLLink : public TCAVLLinkAggregate<t_CParamsLink>
{
public:
TCAVLLink()
{
}
};
#define DIdsPOffsetOf(_Type, _Member) ((aint)(&((_Type *)4)->_Member)-4)
# define DIdsTreeAVL_Trans(_Class, _Member) \ class CAVLTree_Translator##_Member \ {\ public:\ DIdsPInlineS static aint GetOffset()\ {\ return (aint)DIdsPOffsetOf(_Class, _Member);\ }\ };\
# define DIdsTreeAVLAligned_LinkType(_cClass, _Member, _cKey, _cCompare) NIds::NTree::TCAVLLink< NIds::NTree::TCAVLTreeParams<_cClass, _cKey, NIds::NTree::TCAVLLinkAlignedData<NIds::CDefaultPointerHolder>, _cClass::CAVLTree_Translator##_Member, _cCompare, DIdsDefaultAllocator > >
# define DIdsTreeAVLAligned_Member(_cClass, _Member, _cKey, _cCompare) DIdsTreeAVLAligned_LinkType(_cClass, _Member, _cKey, _cCompare) _Member;
# define DIdsTreeAVLAligned_Link(_cClass, _Member, _cKey, _cCompare) \ DIdsTreeAVL_Trans(_cClass, _Member) \ DIdsTreeAVLAligned_Member(_cClass, _Member, _cKey, _cCompare)
# define DIdsTreeAVLAlignedA_LinkType(_cClass, _Member, _cKey, _cCompare) NIds::NTree::TCAVLLinkAggregate< NIds::NTree::TCAVLTreeParams<_cClass, _cKey, NIds::NTree::TCAVLLinkAlignedData<NIds::CDefaultPointerHolder>, _cClass::CAVLTree_Translator##_Member, _cCompare, DIdsDefaultAllocator > >
# define DIdsTreeAVLAligned_Tree(_cClass, _Member, _cKey, _cCompare) NIds::NTree::TCAVLTree<DIdsTreeAVLAlignedA_LinkType(_cClass, _Member, _cKey, _cCompare)::CParams>
# define DIdsTreeAVLAlignedA_Tree(_cClass, _Member, _cKey, _cCompare) NIds::NTree::TCAVLTreeAggregate<DIdsTreeAVLAlignedA_LinkType(_cClass, _Member, _cKey, _cCompare)::CParams>
# define DIdsTreeAVLAligned_Iterator(_cClass, _Member, _cKey, _cCompare) DIdsTreeAVLAlignedA_Tree(_cClass, _Member, _cKey, _cCompare)::TIterator<DIdsTreeAvlDefaultIteratorRecursionDepth>
}
}
class CTest
{
public:
int m_Member0;
int m_Member1;
class CCompare
{
public:
};
DIdsTreeAVLAligned_Link(CTest, m_Link, int, CCompare);
};
int _tmain(int argc, _TCHAR* argv[])
{
DIdsTreeAVLAligned_Tree(CTest, m_Link, int, CTest::CCompare) Tree;
DIdsTreeAVLAligned_Iterator(CTest, m_Link, int, CTest::CCompare) Iter = Tree;
while (Iter)
{
Iter->m_Member0 = 0;
Iter. // Here m_IteratorMember should be shown
Iter-> // Here m_Link, m_Member0 and m_Member1 should be shown. Although they are shown here, it's probably for the wrong reason (Tree shows the same)
Tree. // Mere m_TreeMember should be shows
++Iter;
}
return 0;
}