This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
C++: templates
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: C++: templates
- From: <zvyagin at gams dot ihep dot su>
- Date: Thu, 29 Jul 1999 22:28:11 +0400 (MSD)
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.