To: djgpp AT delorie DOT com Message-Id: Mime-Version: 1.0 Organization: Moscow State University Branch in Ulianovsk, MMF From: akondra AT mmf DOT univ DOT simbirsk DOT su (A.V. Kondratiev) Date: Thu, 26 Dec 96 13:32:59 +0300 Subject: C++ inline members in templates are not expanded Lines: 41 It is something strange with inline members in templates. In the following sample template class Array { public: Array(unsigned sz = 0 ): data(0), lim(sz) { if (lim) data = new T[sz]; } ~Array() { if (data) delete [] data; } inline T & operator [] ( unsigned index ) const { return data[index]; } protected: T * data; unsigned lim; }; int main() { Array a(10); int i; i=a[5]; //!!!!!!!!!!!!!!! return 0; } Array::operator[] is not expanded inline compiling by gcc 2.7.2.1 gcc -S -O -g0 name.cc. I tried different options but it seems that compiler does not pay attention to inline directive in templates . Particularly Array::operator[] must be inline without any 'inline' directives because it's body is in the class declaration and such simple members are really needed to be inline! HOW? Please, send your answers to my e-mail. Thank you. Aleksey V. Kondratyev, Simbirsk, Russia akondra AT mmf DOT univ DOT simbirsk DOT su