Static members in templates in egcs-1.0.1
dave madden
dhm@paradigm.webvision.com
Wed Jan 14 23:17:00 GMT 1998
=>supernova% g++ -pedantic test.C
=>test.C:6: warning: ANSI C++ forbids in-class initialization of
=>non-const static member `mycounter'
I've been trying to find out for a while: does the C++ spec allow you
to define static consts in the class definition? Egcs & g++ do, but
all the compilers I've tried on NT complain. Here's what I'd like to
do:
template <class T> class foo {
class bar {
int xxx;
T ttt;
} ;
public:
static const size_t BAR_SIZE = sizeof(bar);
static const int T_OFFSET = (int)(&((bar *)0)->ttt);
// ... and various other address, padding, etc. calculations
} ;
Am I legal?
Thanks,
d.
More information about the Gcc
mailing list