On Mon, Apr 04, 2005 at 12:15:07PM +0200, tbp wrote:
> On Apr 4, 2005 11:54 AM, Nathan Sidwell <[EMAIL PROTECTED]> wrote:
> > > Am i missing something obvious?
> > well, not 'obvious', but that is what [14.7.3]/2 says.
> I especially don't quite get why specialization have to be defined
> that way when non specialized version don't have to, ie that is legit:
> namespace dummy {
> struct foo {
> template <int i> void f();
> };
> }
> template<int i> void dummy::foo::f() { }
That's not an explicit specialisation, so the same rules don't apply.
That's just a definition of the primary template.
[14.7.3]/2 says that the *declaration* of an explicit specialisation
must appear in the same namespace. The *definition* can appear in an
enclosing namespace (as with your example above,) so you can do this:
namespace dummy {
struct foo {
template <int i> void f() {}
};
template<> void foo::f<666>(); // declare specialisation
}
template<> void dummy::foo::f<666>() {} // define specialisation
Hope that helps,
jon
--
Prediction is very difficult, especially about the future.
- Niels Bohr