M
Mark P
I was helping a coworker port some code to a new compiler (HP). He had
something along the lines of this:
class C { // defined in the global namespace
static int foo();
};
namespace {
int C::foo() {...}
};
The compiler complained: A definition of a namespace declaration
must be written in directly in the namespace (unqualified) or in an
enclosing namespace (qualified).
The fix of course is obvious, and I'm not sure what his motivation was
to put only the definition in the unnamed namespace, but two other
compilers (Linux gcc and Sun) had not complained about this.
So I wonder, is his code standard compliant or not? (And if so, is
there any reason why one would want to do this?)
Thanks,
Mark
something along the lines of this:
class C { // defined in the global namespace
static int foo();
};
namespace {
int C::foo() {...}
};
The compiler complained: A definition of a namespace declaration
must be written in directly in the namespace (unqualified) or in an
enclosing namespace (qualified).
The fix of course is obvious, and I'm not sure what his motivation was
to put only the definition in the unnamed namespace, but two other
compilers (Linux gcc and Sun) had not complained about this.
So I wonder, is his code standard compliant or not? (And if so, is
there any reason why one would want to do this?)
Thanks,
Mark