Returning Vectors standard in C++

后端 未结 4 1479
被撕碎了的回忆
被撕碎了的回忆 2021-01-26 12:20

Now, I know this is a common question, but I haven\'t been able to really find a straight answer on this. This is really a question about standards. I am working on a project in

4条回答
  •  死守一世寂寞
    2021-01-26 12:44

    Is the only solution to pass a "resultant" vector by reference?

    No. You can also pass an iterator, like algorithms do:

    void func( InputIt first, InputIt last, OutputIt res);
    

    you can then make this a template:

    template< class InputIt, class OutputIt >
    void func( InputIt first, InputIt last, OutputIt res);
    

提交回复
热议问题