B
Bonzo
I'm trying to write a class for a smart pointer. I'm having a problem
though when trying to implement operator== with both sides being a Smart.
(Or any function that I try to bring U into.)
The pointer contained might not be the exact same type but still get
tested for equality. Here's what I have:
template <typename T> class Smart;
template<typename T, typename U>
bool operator== ( const Smart<T>& a, const Smart<U>& b );
template <typename T> class Smart
{
/* On the next line, GCC says:
"type/value mismatch at argument 1 in template parameter list for
`template<class T> class Smart expected a type, got `U'"
*/
friend bool operator== ( const Smart<T>& a, const Smart<U>& b );
// friend bool operator==<> ( const Smart<T>& a, const Smart<U>& b );
}
bool operator== (const Smart<T>& a, const<SmartU>& b)
{
return true;
}
It also warns about the angle brackets not being there, which are in the
commented out line, but adding them does not solve the error.
What must I do to make the compiler happy?
Thanks,
-Jim
though when trying to implement operator== with both sides being a Smart.
(Or any function that I try to bring U into.)
The pointer contained might not be the exact same type but still get
tested for equality. Here's what I have:
template <typename T> class Smart;
template<typename T, typename U>
bool operator== ( const Smart<T>& a, const Smart<U>& b );
template <typename T> class Smart
{
/* On the next line, GCC says:
"type/value mismatch at argument 1 in template parameter list for
`template<class T> class Smart expected a type, got `U'"
*/
friend bool operator== ( const Smart<T>& a, const Smart<U>& b );
// friend bool operator==<> ( const Smart<T>& a, const Smart<U>& b );
}
bool operator== (const Smart<T>& a, const<SmartU>& b)
{
return true;
}
It also warns about the angle brackets not being there, which are in the
commented out line, but adding them does not solve the error.
What must I do to make the compiler happy?
Thanks,
-Jim