C++: template in namespace

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Tue Aug 10 00:35:00 GMT 1999


>   /* We have not yet called push_template_decl to turn the
>      FUNCTION_DECL into a TEMPLATE_DECL, so the declarations
>      won't match.  But, we'll check later, when ...?  */
> 
> I don't know what comes in the `when', but I'm sure you had something
> in mind.

I haven't located the right spot, yet, but I felt it is better to not
complain about ill-formed code but to complain about correct one; at
least for 2.95.1. The specific test case is

namespace bar
{
  template <typename T>
  T const foo(T const &);
  template<> const int foo<int>(int const &);
}

template <typename T>
T const
bar::foo(T const &a)
{
  return a;
}

template<> const int bar::foo<int>(int const &){return 0;}


Please not that another of similar case aren't check, either:

namespace N {
  template<class,class>class X;
}

template<class>class N::X{};

I'm not sure where the check (must be correctly declared in N) is
supposed to happen.

Regards,
Martin



More information about the Gcc-patches mailing list