Template in namespace defined outside
Benko Pal
benko@sztaki.hu
Thu Dec 9 04:53:00 GMT 1999
If a template is just declared within a namespace but defined outside,
strange things happens. I'm using gcc-2.95.2.
namespace ns
{
template <typename T> struct simple;
template <typename T> struct difficult;
}
template <typename T>
struct ns::simple
{
simple<T> &operator =(simple<T> const &);
void empty() const;
};
template <typename T>
ns::simple<T> &
ns::simple<T>::operator =(simple<T> const &a)
{
return *this;
}
template <typename T>
void
ns::simple<T>::empty() const
{}
template <typename T>
struct ns::difficult
{
difficult();
~difficult();
difficult &foo();
void bar(difficult const &);
T const default() const;
};
template <typename T>
ns::difficult<T>::difficult()
{}
template <typename T>
ns::difficult::~difficult()
{}
template <typename T>
ns::difficult<T> &
ns::difficult<T>::foo()
{
return *this;
}
template <typename T>
void
ns::difficult<T>::bar(difficult<T> const &)
{}
template <typename T>
T const
ns::difficult<T>::default() const
{
return T();
}
int
main()
{
ns::simple<int> a, b;
a.empty();
a = b;
return 0;
}
More information about the Gcc-bugs
mailing list