我有以下问题:
当我尝试清除 v_doc 并保留最后一个元素时,出现以下错误:
C:\Users\hdaher\Documents\Project\CR_Verification\main.cpp|292|error: no matching function for call to 'std::vector
::clear(std::vector >::iterator, __gnu_cxx::__normal_iterator*, std::vector > >)'|
#include <memory>
#include <iostream>
using namespace std;
int main()
{
//Declare a vector of type Document
vector<shared_ptr<Document>> v_doc;
//Works ok
v_doc.clear();
//Error HERE!! Clearn V_doc and keep only the last element
v_doc.clear(v_doc.begin(),v_doc.end()-1);
return 0;
}
最佳答案
关于c++ - vector<shared_ptr<>> 清除错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20043990/