lets say i have some code
how could I get Inner to be the default argument for the template?Code:template <class Type1, class Type2 = ???> class Outer { class Inner {}; };
lets say i have some code
how could I get Inner to be the default argument for the template?Code:template <class Type1, class Type2 = ???> class Outer { class Inner {}; };
Last edited by *ClownPimp*; 06-18-2003 at 06:09 PM.
C Code. C Code Run. Run Code Run... Please!
"Love is like a blackhole, you fall into it... then you get ripped apart"
Try giving it a forward declaration outside the class, perhaps.
Code:class Outer::Inner; template <class Type1, class Type2 = Inner> class Outer { class Inner {}; };
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
Never mind... that failed horribly... I'll see if I can figure it out though.
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
You might be able to get:
class Outer;
class Outer::Inner;
class Outer { //...
to work.
I tried many variations on that with GCC to no avail (nothing quite like guess-n-check programming, eh?).
To be honest, I'm not entirely sure its possible. Since something inside the class is would be responsible in part for defining its own type, the logic seems like it'd become circular to have Inner as a valid template argument.
Heres my rationale (anyone, feel free to shoot holes in this, I'm just trying to reason my way through this):
You have four types, A1, A2, B1, B2.
Outer<A1, A2> is a different type from Outer<B1, B2>, and consequently, Outer<A1, A2>::Inner is a different type from Outer<B1, B2>::Inner. Therefore, the type Outer::Inner is incomplete, and therefore, cannot fully define another type. It would be valid to have Outer<A1, A2>::Inner as one of the template parameters, but not Outer::Inner.
Consider this:
You have Outer<T1, Inner>. Inner is of course (as it is completely defined) Outer<T1, Inner>::Inner, so your declaration is something like this:
Outer<T1, Outer<T1, Outer<T1, ... ad infinitum ...>::Inner>::Inner>, which clearly doesn't work.
Anyways, I may be totally off, but it seems to make sense (at the moment at least).
Cheers
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
That makes sense, thanks.
C Code. C Code Run. Run Code Run... Please!
"Love is like a blackhole, you fall into it... then you get ripped apart"