streamoverloadingstdostreammanipulators

overloading stream manipulator operator


Hi I am trying to overload the operator<< to hook into

stream << std::endl;

to avoid '\n' to be appended if I don't need output. I alredy overloaded:

std::ostream& operator<< (std::ostream& (*pf)(std::ostream&))
std::ostream& operator<< (std::ios& (*pf)(std::ios&))
std::ostream& operator<< (std::ios_base& (*pf)(std::ios_base&))

But the call ends always at basic_ostream

_Myt& __CLR_OR_THIS_CALL operator<<(_Myt& (__cdecl *_Pfn)(_Myt&))
{// call basic_ostream manipulator
    _DEBUG_POINTER(_Pfn);
    return ((*_Pfn)(*this));
}

Solution

  • Found the solution myself

    Problem was that other overloaded operators returned std::ostream& so the overloaded function could not be called.