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 > > >