Unformatted output in operator <<
I have a class that contains decoded video frames. I would like my decod开发者_运维技巧er to use an output_iterator
to write those frames to different targets. In order to support writing directly to a file, I want to overload operator <<
for my decoded frame class (for use with ostream_iterator
). The problem is, that operator <<
is meant to be used for formatted output, but I want to do unformatted output with it. Are there any pitfalls to be considered? Is there another solution, or is it OK to just go with that?
std::basic_ostream
is indeed mainly to be used for formatted output. (I say "mainly" because it does have a method for unformatted output. But that's not accessible through output iterators.) For unformatted output, use a stream buffer iterator.
use the unformatted out put function like getchar, fgets
精彩评论