tom_usenet <tom_usenet@hotmail.com> wrote in message news:<q45vf0pr406iqt9hrafnpmi9i554pf5cjt@4ax.com>. ..[color=blue]
> On 22 Jul 2004 00:38:34 -0700,
sargon@gmail.com (Sargon) wrote:
>[color=green]
> >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)[/color]
>
> No it doesn't, your code contains no "Wrapper" class at all![/color]
Oh my... I mistakenly posted the modified code... here's the
correct one:
==================================================
#include <iostream>
using namespace std;
enum colour_t { White, Black };
class Wrapper
{
public:
static void f(void);
template <colour_t c> static void f(void);
};
void Wrapper::f(void)
{
cout << "Hello from colourless f" << endl;
}
template <colour_t c>
void Wrapper::f(void)
{
if(c == White) cout << "Hello from white f" << endl;
else cout << "Hello from black f" << endl;
}
int main(void)
{
Wrapper::f();
Wrapper::f<White>();
Wrapper::f<Black>();
return 0;
}
==================================================
[color=blue][color=green]
> >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.[/color][/color]