I'm getting an ambiguous operator error, and I'm not sure why.
I've dumbed down the example. Can anyone spot the problem?
Code:template<typename T, bool ReadOnly> class buffered_stream_iterator;
template<typename T, bool ReadOnly, typename T2> T2& operator += (T2& lhs, const buffered_stream_iterator<T, ReadOnly>& rhs);
template<typename T, bool ReadOnly>
class buffered_stream_iterator:
public std::iterator<std::random_access_iterator_tag, T>
{
public:
template<typename ThisT, bool ReadOnly, typename T2> friend T2& operator += (T2& lhs, const buffered_stream_iterator<ThisT, ReadOnly>& rhs);
};
template<typename T, bool ReadOnly, typename T2> T2& operator += (T2& lhs, const buffered_stream_iterator<T, ReadOnly>& rhs)
{
return lhs;
}
int main()
{
buffered_stream_iterator<wchar_t, false> Test;
int n = 0;
n += Test;
return 0;
}
I'd appreciate any help.Quote:
1>error C2593: 'operator +=' is ambiguous
1> could be 'T2 &operator +=<ElemType_t,false,int>(T2 &,const buffered_stream_iterator<T,ReadOnly> &)' [found using argument-dependent lookup]
1> with
1> [
1> T2=int,
1> T=ElemType_t,
1> ReadOnly=false
1> ]
1> or 'T2 &operator +=<ElemType_t,false,int>(T2 &,const buffered_stream_iterator<T,ReadOnly> &)'
1> with
1> [
1> T2=int,
1> T=ElemType_t,
1> ReadOnly=false
1> ]
1> while trying to match the argument list '(int, buffered_stream_iterator<T,ReadOnly>)'
1> with
1> [
1> T=ElemType_t,
1> ReadOnly=false
1> ]