Suresh, Can you tell me what the actual gcc error is? corey On 6/20/05, Suresh T <suresh.t@xxxxxxxxxxx> wrote: > hi corey, > > >> What type of objects are contained_size and inner_object? > > Sorry, that was a typo (not in the actual code but in the mail that i > sent). > (Instead of putting the actual code, i wanted to put in a short one > illustrating the problem!!) > > > inner_object is an object of class contained (which was correct in the > mail). This is within the class "enclosing". The "enclosing" > class has a template parameter "size" and contained is created using that > size. WHICH IS WHERE THE PROBLEM ORIGINATES > as i said in the previos mail. > > i.e., contained<size> inner_object; > > and there was a typo in the static_cast . It should be : > (static_cast<contained <size> >( inner_object) ) .fun_inner(); > > > I hope i can get some answer as this looks very gcc specific. > > Thanks in advance > --------------------------------------------------------------------------------------------------------- > > Warm Regards, > Suresh.T > > > > > > > > To > Suresh T/BTC/SC/PHILIPS@PHILIPS > cc > corey taylor gcc-help@xxxxxxxxxxx > Subject > Sent by: Re: template class within another : > gcc-help-owner@xxxxx problem with gcc 3.2.3 on linux > nu.org (BUG ??) > Classification > 06/20/2005 08:17 PM > > Please respond to > corey taylor > <corey.taylor@gmail. > com> > > > > > > > Suresh, > > What type of objects are contained_size and inner_object? > > corey > > On 6/20/05, Suresh T <suresh.t@xxxxxxxxxxx> wrote: > > hi, > > > > I need to use a template class object within another template class. > > Specifically gcc (3.2.3 on linux) gives me a problem when the INNER > > TEMPLATE OBJECT IS CREATED USING THE TEMPLATE PARAMETER OF THE ENCLOSING > > CLASS and when i call the inner class object function from the enclosing > > class object function.. > > AS this works fine in MS VC7 so i wanted to know if this is some bug in > > gcc > > > > Example : > > In the below example the "enclosing" class contains an object of > > "contained" class. The contained object is created using the > > template parameter of "enclosing" class. When the "enclosing" class > > function is called, we call the function of the inner object. > > > > template <std::size_t size> > > class contained { > > public: > > template <std::size_t sub_size> > > int func_inner(){ ... } > > > > }; > > > > template < std::size_t size> > > class enclosing { > > > > public: > > > > template <std::size_t sub_size> > > int func_enclose(){ ... > > > > return > > (static_cast<contained_size>( inner_object) ) .fun_inner(); > > // > > =================THIS GIVES AN ERROR ======================== > > MARK1 > > } > > > > contained<size> inner_object; // ============== THIS IS THE > > ORIGIN OF ERROR ? ===================== MARK2 > > > > }; > > > > > > Note : The error disappears if i use a specific value when creating the > > inner_object ( MARK 2 above) > > That is instead of "contained<size> inner_object" if i use "contained > <N> > > inner_object" where N is any number like 32. > > (Even in that case i need to use a static_cast ( see MARK 1) to remind > the > > compiler of the data type of inner_object otherwise > > the compiler gives an error which i find strange.) > > > > I cant use a specific value for the inner object as it should take it > from > > the enclosing class template parameter. Since this is > > not working i would greatly appreciate if someone can tell me whether > this > > is a gcc bug or if i need to do something special to let the compiler > > know what i am trying to do. > > > > Thanks & > > > --------------------------------------------------------------------------------------------------------- > > > > > Warm Regards, > > Suresh.T > > > > > > > > >