'recursive' template problem

From: Alexander Stippler (stip_at_mathematik.uni-ulm.de)
Date: 07/16/04


Date: Fri, 16 Jul 2004 17:54:47 +0200

Hi,

I have a little problem to design some template classes in a realizable way.
I have some Container classes and some Proxy classes (proxies for
elements). Looks like this:

// P is the Proxy class.
template <typename T, typename P>
class Container
{
    P
    whatever() { return P(); }
};

template <typename T>
class Proxy1 { ... };

template <typename T>
class Proxy2 { ... };

For some reason every instance of class Proxy needs to know, which Container
class it is used for. Some behavior of Proxy is dependend on the specific
Container. So, when I call method whatever() I want to give the information
that I'm inside Container<T, P> to P. But I cannot give the Proxy class the
information via another template parameter, cause I would end up in an
endless recursive definition, since Container is parameterized by the
Proxy. Got my problem?

Best regards,
        alex



Relevant Pages

  • traits help
    ... I am learning template programming and there is a problem about ... Now consider a container and an iterator. ... template <typename T> ...
    (comp.lang.cpp)
  • Re: recursive template problem
    ... Some behavior of Proxy is dependend on the specific ... since Container is parameterized by the ... template class P> ... mean it is not a valid type. ...
    (comp.lang.cpp)
  • Re: Statically AND Dynamically Typed Language ??
    ... (say easier to implement the language) ... typing instead of with the template mechanisms? ... element type you have an independent instance of the container type. ... You mean for generics, right? ...
    (comp.lang.misc)
  • Re: Maintance of c++ code
    ... iterator constant in the standard, ... template ... template <class Iter_> ... container, some only work with particular containers. ...
    (comp.object)
  • Re: Teaching 5th graders
    ... used a heavy tissue paper over the cups and I had pre-cut 'windsheilds' of clay. ... I like the idea of the toothbrush and tarpaper - may use it ... Wrap the paper on the container ... Your template will ...
    (rec.crafts.pottery)