The goal is to make a friend function of an inner template class...
template < typename T >
class Foo {
public:
class Bar {
friend bool operator==(
const typename Foo<T>::Bar& lhs, const typename Foo<T>::Bar& rhs);
};
};
template < typename T >
bool operator==(cons t typename Foo<T>::Bar& lhs, const typename
Foo<T>::Bar& rhs)
{
bool result = false;
return result;
}
#include <cassert>
int main()
{
Foo<int>::Bar a;
bool r = a == a;
assert( r == false );
}
Comeau says:
"bool operator==(cons t Foo<T>::Bar &, const Foo<T>::Bar &)" declares a
non-template function -- add <to refer to a template instance
friend bool operator==(cons t typename Foo<T>::Bar& lhs, const
^
typename Foo<T>::Bar& rhs);
GCC compiles but complains at link time:
ZeroLink: unknown symbol '__ZeqRKN3FooIi E3BarES3_'
What am I doing wrong?
template < typename T >
class Foo {
public:
class Bar {
friend bool operator==(
const typename Foo<T>::Bar& lhs, const typename Foo<T>::Bar& rhs);
};
};
template < typename T >
bool operator==(cons t typename Foo<T>::Bar& lhs, const typename
Foo<T>::Bar& rhs)
{
bool result = false;
return result;
}
#include <cassert>
int main()
{
Foo<int>::Bar a;
bool r = a == a;
assert( r == false );
}
Comeau says:
"bool operator==(cons t Foo<T>::Bar &, const Foo<T>::Bar &)" declares a
non-template function -- add <to refer to a template instance
friend bool operator==(cons t typename Foo<T>::Bar& lhs, const
^
typename Foo<T>::Bar& rhs);
GCC compiles but complains at link time:
ZeroLink: unknown symbol '__ZeqRKN3FooIi E3BarES3_'
What am I doing wrong?
Comment