creating an ostream

前端 未结 4 592
走了就别回头了
走了就别回头了 2021-01-05 08:09

I am trying to create a c++ ostream for educational reasons. My test will be creating an ostream that acts like a ofstream would except instead of writing to a file it would

4条回答
  •  既然无缘
    2021-01-05 09:09

    I'll just remark that you don't have to write an ostream-like class for that. You can use an adapter to achieve your goal.

    For example, this code reads from istream and inserts each element into a vector:

    vector V;
    copy(istream_iterator(cin), 
         istream_iterator(), 
         back_inserter(V)); 
    

提交回复
热议问题