Changing the reserve memory of C++ vector

前端 未结 5 1350
情深已故
情深已故 2021-01-06 00:29

I have a vector with 1000 \"nodes\"

 if(count + 1 > m_listItems.capacity())
     m_listItems.reserve(count + 100);

The problem is I also

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-06 00:59

    You could try this technique from here

    std::vector< int > v;
    // ... fill v with stuff...
    std::vector< int >().swap( v );
    

提交回复
热议问题