Listing 4
(a)template<class Src, class Dst> class Member_Link : public Typed_Link<Src, Dst> { Dst Src::*mptr; public: Member_Link(Dst Src::*_mptr) : mptr(_mptr) {} Dst &traverse(Src &s) { return s.*mptr; } // ... };(b)
template<class Src, class Dst, class Get = Dst &(Src::*)(void) const> class Get_Link : public Typed_Link<Src, Dst> { Get get; public: Dst &traverse(Src &s) { return (s.*get)(); } // ... };(c)
template<class Src, class Dst> class Array_Link : public Typed_Link<Src, Dst> { unsigned int index; public: Dst &traverse(Src &id) { if (index >= sizeof(Src)/sizeof(Dst)) { throw Clank(id); } return id[Index]; } // ... };