This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

C++: templates


Dear g++ developers!
 
My friend Alexander Shvorob sent me piece of code that demonstrated
one problem with template arguments.

// File 2.c  ---------------------- CUT HERE ---------
class Store { public: int i1,i2; } s;
template <int *N> class Test {};

int main()
{
  Test<&s.i1> ok; 
  Test<&s.i2> bad;
}
// -------------------------------- CUT HERE ---------

$ g++ 2.c
2.c: In function `int main()':
2.c:8: `(&s + 4)' is not a valid template argument
2.c:8: it must be the address of an object with external linkage
2.c:8: ANSI C++ forbids declaration `bad' with no type

$ g++ -v
Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/2.95/specs
gcc version 2.95 19990718 (prerelease)

With best wishes,
Alexander Zvyagin.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]