views:

72

answers:

2

I have a class that contains decoded video frames. I would like my decoder 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?

+1  A: 

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.

sbi
I was not aware of that class, thank you!
Space_C0wb0y
A: 

use the unformatted out put function like getchar, fgets

in c++ some unformated output function are usefull just try it . it will work