S
Sargon
Hi
I have a problem with C++ traits. The following lil program provides a
Wrapper class which contains 3 static methods. (1 normal, 2 as a
template)
======================================================
#include <iostream>
using namespace std;
enum colour_t { White, Black };
static void f(void);
template <colour_t c> static void f(void);
static void f(void)
{
cout << "Hello from colourless f" << endl;
}
template <colour_t c>
void f(void)
{
if(c == White) cout << "Hello from white f" << endl;
else cout << "Hello from black f" << endl;
}
int main(void)
{
f();
f<White>();
f<Black>();
return 0;
}
======================================================
The thing compiles w/o problems under Linux (gcc 3.3.3 under gentoo)
and Cygwin (gcc 3.3.1 under WinNT) and produces the expected output:
Hello from colourless f
Hello from white f
Hello from black f
Under MacOSX however (gcc 3.3 20030304) gives the following compile
error:
test.cxx:23: error: redefinition of `static void Wrapper::f()'
test.cxx:16: error: `static void Wrapper::f()' previously declared
here
test.cxx:23: error: no `static void Wrapper::f()' member function
declared in
If the static functions are defined outside the wrapper class, it
compiles fine.
Any idea what's wrong? I'm asking in a non-OSX newsgroup because I'd
like to know whether the program above is really standard-compliant or
not.
Regards,
Sargon
I have a problem with C++ traits. The following lil program provides a
Wrapper class which contains 3 static methods. (1 normal, 2 as a
template)
======================================================
#include <iostream>
using namespace std;
enum colour_t { White, Black };
static void f(void);
template <colour_t c> static void f(void);
static void f(void)
{
cout << "Hello from colourless f" << endl;
}
template <colour_t c>
void f(void)
{
if(c == White) cout << "Hello from white f" << endl;
else cout << "Hello from black f" << endl;
}
int main(void)
{
f();
f<White>();
f<Black>();
return 0;
}
======================================================
The thing compiles w/o problems under Linux (gcc 3.3.3 under gentoo)
and Cygwin (gcc 3.3.1 under WinNT) and produces the expected output:
Hello from colourless f
Hello from white f
Hello from black f
Under MacOSX however (gcc 3.3 20030304) gives the following compile
error:
test.cxx:23: error: redefinition of `static void Wrapper::f()'
test.cxx:16: error: `static void Wrapper::f()' previously declared
here
test.cxx:23: error: no `static void Wrapper::f()' member function
declared in
If the static functions are defined outside the wrapper class, it
compiles fine.
Any idea what's wrong? I'm asking in a non-OSX newsgroup because I'd
like to know whether the program above is really standard-compliant or
not.
Regards,
Sargon