template<typename T> FowardIt& operator<<(const T&t)
Make the const parameter as shown above. Because temporary persons cannot be associated with a non-constant link. You do not need to define another function. Just enter const parameter, the problem will be solved.
It would also be better if you made a const function template by putting const in the far right of the function as:
template<typename T> const FowardIt& operator<<(const T&t) const ^^^^^ ^^^^^ ^^^^^ | | | | | put const here as well | put const here | You've to make the return-type also const since it can't return non-const reference anymore
If you do this, you can call this function on const objects as well:
void f(const FowardIt &o)
source share