This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[c++] explicit instantiations + namespaces



Hey jason. Just ran across this: it looks like properly scoped explicit
instantiations are not being looked up correctly.

%COMP.sh test.cc 
test.cc:25: `void std::swap(string&, string&)' should have been declared inside    `std'
test.cc:25: non-template used as template

It can be worked around by enclosing in a namespace, but
explicitly-qualified namespaces should work too.

-benjamin


// test.cc
namespace std
{
  template<typename _CharT, typename _Traits>
  class basic_string {};

  template<typename _CharT, typename _Traits>
    inline void
    swap(basic_string<_CharT, _Traits>& __lhs, 
	 basic_string<_CharT, _Traits>& __rhs)
    { }

  typedef basic_string<int, int> string;
}

#if 0
// works
namespace std
{ template void swap(string&, string&); }
#else
// should work, doesn't
template void std::swap(std::string&, std::string&);
#endif

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]