This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[c++] explicit instantiations + namespaces
- To: gcc-bugs at gcc dot gnu dot org, jason at redhat dot com
- Subject: [c++] explicit instantiations + namespaces
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Wed, 3 Jan 2001 12:11:53 -0800
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