Ah yes, from one problem to the other. Template friends are just a pain; this solves the ambiguous operator, but fails to make the friend declaration work. Wonderful, that's what I call it.
Good thing I decided to use an easier approach.
I'm not even going to bother with this approach anymore >_<
EDIT:
Actually, this works!
Code:
#include <iterator>
#include <iostream>
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, bool, typename T2> friend T2& operator += (T2& lhs, const buffered_stream_iterator<T, ReadOnly>& rhs);
private:
int m_Test;
};
template<typename T, bool ReadOnly, typename T2> T2& operator += (T2& lhs, const buffered_stream_iterator<T, ReadOnly>& rhs)
{
std::cout << rhs.m_Test;
return lhs;
}
int main()
{
buffered_stream_iterator<wchar_t, false> Test;
int n = 0;
n += Test;
return 0;
}