Linked Questions
10 questions linked to/from A custom ostream
1 vote
0 answers
300 views
How a streambuf can inform its owner about errors [duplicate]
Lastly I did a lot of work to implement my own stream class in c++. The work is almost done, but there is one last thing... You see I discovered in C++ input and output streams uses an internal std::...
0 votes
0 answers
49 views
How to add functionality to existing C++ standard library functions [duplicate]
Visual Studio 2022 - Community Edition I would like versions of the C++ fstream, ifsteam, and ofstream classes that operate identically to the standard versions except that some of the functions they ...
34 votes
5 answers
10k views
Implementing a no-op std::ostream
I'm looking at making a logging class which has members like Info, Error etc that can configurably output to console, file, or to nowhere. For efficiency, I would like to avoid the overhead of ...
3 votes
5 answers
8k views
Custom stream to method in C++?
I'm making a logger and I wish to have some kind of stream-like happenings going on, ideally doing CLogger << "Testing, " << 1 << ",2,3\n"; instead of CLogger->log("Testing, %i,2,...
8 votes
3 answers
12k views
C++ stream to memory
how can I create std::ostream and std::istream objects to point to a piece of memory I allocated and manage (I don't want the stream to free my memory). I was looking at using rdbuf()->pubsetbuf() ...
-2 votes
1 answer
2k views
How to your own C++ cout << like object
I was just asking if you can create your own cout<< like object in C++. most people confuse my question with operator overloading <<. But no, i dont want to implement my own << ...
2 votes
1 answer
1k views
Check what output is written to standard output
I want to check whether output is written to the standard output (through cout) in a certain part of my program. What I found is a way to block any output by changing the streambuf of cout. (here:C++:...
0 votes
1 answer
619 views
C++ Interface for logger
I am working a big legacy project and need to redo the common logger. I tried to make same logger interface with before to avoiding changing ton of loggers. The reason I need to redo the logger is the ...
0 votes
1 answer
130 views
Having a class that has a write function, how to I pass it to a function accepting std::ostream&
I have an instance of a class which implements a writing interface such as this one: struct Writer { virtual size_t write(const char* buffer, size_t size, size_t offset) = 0; }; I also have a ...
0 votes
0 answers
148 views
"Overriding" non-virtual operator << (...) in user stream
I made my own stream class inherited from std::ostream with a template insertion operator: class MyOstream : public std::ostream { ... template <typename T> std::ostream & operator ...