More info on "Bug with namespace and templates"

Carlo Wood carlo@runaway.xs4all.nl
Tue Dec 15 09:19:00 GMT 1998


Hi again,

it does work with constants and classes, just not with functions:

-----------------------------------------------------------------
namespace N {
  const int i = 1;
  void func(void) {}
  class A {};
};

template<class T>
void foobar(T)
{
  using namespace ::N;
  A a;
  int j = i;
  func();
}

int main(void)
{
  foobar(1);  
  return 0;
}
-----------------------------------------------------------------

~/c++/tests>g++ namespace.cc
namespace.cc: In function `void foobar<int>(int)':
namespace.cc:18:   instantiated from here
namespace.cc:13: `func' undeclared (first use this function)
namespace.cc:13: (Each undeclared identifier is reported only once
namespace.cc:13: for each function it appears in.)

-- 
 Carlo Wood  <carlo@runaway.xs4all.nl>



More information about the Gcc-bugs mailing list