[Insight-developers] template depth limit

Lydia Ng lng@insightful.com
Thu, 28 Jun 2001 17:08:25 -0700


This is a multi-part message in MIME format.

------=_NextPart_000_000A_01C0FFF4.F240A5C0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

I tested it - it happens with regular function
calls too (code attached).

Lydia

> -----Original Message-----
> From: whitaker@cs.utah.edu [mailto:whitaker@cs.utah.edu]
> Sent: Thursday, June 28, 2001 4:47 PM
> To: lng@insightful.com
> Subject: Re: [Insight-developers] template depth limit
> 
> 
> 
> 
> Is this only because it is trying to in-line them?  Or will 
> this happen with
> regular function calls as well?
> 
> Regards,
> 
> Ross
> 
> 
> Lydia Ng wrote:
> 
> > The number of classes instantiated is not the whole
> > picture.
> > You can actually exceed the limit with just one class
> > (see below) if it recursively calls its own member 
> functions enough times.
> >
> > Lydia
> >
> > ----------------------
> >
> > template<class T>
> > class MyClass
> > {
> >
> > public:
> >   MyClass() { f1(); }
> >   void f1(){ f2(); }
> >   void f2(){ f3(); }
> >   void f3(){ f4(); }
> >   void f4(){ f5(); }
> >   void f5(){ f6(); }
> >   void f6(){ f7(); }
> >   void f7(){ f8(); }
> >   void f8(){ f9(); }
> >   void f9(){ f10(); }
> >   void f10(){ f11(); }
> >   void f11(){ f12(); }
> >   void f12(){ f13(); }
> >   void f13(){ f14(); }
> >   void f14(){ f15(); }
> >   void f15(){ f16(); }
> >   void f16(){ f17(); }
> >   void f17(){ f18(); }
> >   void f18(){ f19(); }
> >   void f19(){ std::cout << "hello" << std::endl; }
> >
> > };
> >
> > _______________________________________________
> > Insight-developers mailing list
> > Insight-developers@public.kitware.com
> > http://public.kitware.com/mailman/listinfo/insight-developers
> 
> --
> Ross T. Whitaker, Assistant Professor
> 50 S. Central Campus Drive, Rm. 3190
> University of Utah
> Salt Lake City, UT  84112-9205
> voice: 801/587-9549, fax: 801/581-5843
> web: www.cs.utah.edu/~whitaker
> 
> 
------=_NextPart_000_000A_01C0FFF4.F240A5C0
Content-Type: application/octet-stream;
	name="test2.cxx"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="test2.cxx"

#include <iostream>

template<class T>
class MyClass
{

public:
  MyClass();
  void f1(); void f2(); void f3(); void f4(); void f5(); 
  void f6(); void f7(); void f8(); void f9(); void f10();
  void f11(); void f12(); void f13(); void f14(); void f15(); 
  void f16(); void f17();

};

template<class T>
MyClass<T>::
MyClass()
{ f1(); }

template<class T>
void
MyClass<T>::
f1(){ f2(); }

template<class T>
void
MyClass<T>::
f2(){ f3(); }

template<class T>
void
MyClass<T>::
f3(){ f4(); }

template<class T>
void
MyClass<T>::
f4(){ f5(); }

template<class T>
void
MyClass<T>::
f5(){ f6(); }

template<class T>
void
MyClass<T>::
f6(){ f7(); }

template<class T>
void
MyClass<T>::
f7(){ f8(); }

template<class T>
void
MyClass<T>::
f8(){ f9(); }

template<class T>
void
MyClass<T>::
f9(){ f10(); }

template<class T>
void
MyClass<T>::
f10(){ f11(); }

template<class T>
void
MyClass<T>::
f11(){ f12(); }

template<class T>
void
MyClass<T>::
f12(){ f13(); }

template<class T>
void
MyClass<T>::
f13(){ f14(); }

template<class T>
void
MyClass<T>::
f14(){ f15(); }

template<class T>
void
MyClass<T>::
f15(){ f16(); }

template<class T>
void
MyClass<T>::
f16(){ f17(); }

template<class T>
void
MyClass<T>::
f17(){ f18(); }

template<class T>
void
MyClass<T>::
f18(){ f19(); }

template<class T>
void
MyClass<T>::
f19(){ std::cout << "hello" << std::endl; }


int main()
{
   MyClass<double> aa;

   return 0;
  
}
------=_NextPart_000_000A_01C0FFF4.F240A5C0--