B
BigBrian
I have some code, that resembles the following...
class Foo
{
template < class T >
Foo & operator << ( T const & t ) { ... }
};
class AnotherClass
{
friend Foo & operator << ( Foo &, AnotherClass & );
};
Foo & operator << ( Foo &, AnotherClass & )
{
....
}
int main()
{
Foo f;
AnotherClass a;
f << a;
}
The f << a; statemement above ends up calling the template function
Foo & Foo:perator <<( AnotherClass const & )
however I want it to call the friend of Another class, ie
Foo & operator << ( Foo&, AnotherClass & )
How do I accomplish this? Basically, I want to limit the template
expansion of Foo:perator << to NOT include AnotherClass as a
parameter, so the compiler finds the friend function to AnotherClass
instead. Any help is appreciated.
-Brian
class Foo
{
template < class T >
Foo & operator << ( T const & t ) { ... }
};
class AnotherClass
{
friend Foo & operator << ( Foo &, AnotherClass & );
};
Foo & operator << ( Foo &, AnotherClass & )
{
....
}
int main()
{
Foo f;
AnotherClass a;
f << a;
}
The f << a; statemement above ends up calling the template function
Foo & Foo:perator <<( AnotherClass const & )
however I want it to call the friend of Another class, ie
Foo & operator << ( Foo&, AnotherClass & )
How do I accomplish this? Basically, I want to limit the template
expansion of Foo:perator << to NOT include AnotherClass as a
parameter, so the compiler finds the friend function to AnotherClass
instead. Any help is appreciated.
-Brian