lundi 7 décembre 2015

Recursive template classes

I'm not sure whether the title is quiet descriptive, but here is briefly my situation: I have two classes that need to keep references of each other as follows

template <typename S>
class H { 
public:
  H(const S& s): s_{s} {}
private:
  const S& s_;
}

And then

template <typename H>
class S { 
public:
  S(const H& h): h_{h} {}
private:
  const H& h_;
}

There is no doubt I can define anything like

Service<ItsHandler<Service<....> 

Any better idea?

Aucun commentaire:

Enregistrer un commentaire