[c++] explicit instantiations + namespaces
Benjamin Kosnik
bkoz@redhat.com
Wed Jan 3 12:12:00 GMT 2001
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
More information about the Gcc-bugs
mailing list