开发者

Unformatted output in operator <<

开发者 https://www.devze.com 2022-12-25 14:27 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号