求助List erase()如何调用 为什么我这个会报错啊
#include<bits/stdc++.h>
using namespace std;
int read()
{
int xr=0,F=1; char cr;
while(cr=getchar(),cr<'0'||cr>'9') if(cr=='-') F=-1;
while(cr>='0'&&cr<='9')
xr=(xr<<3)+(xr<<1)+(cr^48),cr=getchar();
return xr*F;
}
int n;
int main()
{
list<int> L;
n=read();
for(int i=1;i<=n;i++)
{
string op;
cin>>op;
if(op[0]=='R')
{
int x=read();
L.push_back(x);
}
if(op[0]=='D')
{
int k;
k=read();
L.erase(k);
}
if(op[0]=='L')
{
int x;
x=read();
L.push_front(x);
}
if(op[0]=='I')
{
if(op[1]=='L')
{
int k=read(),x=read();
L.insert(k,x);
}
else
{
int k=read(),x=read();
L.insert(k+1,x);
}
}
}
for(auto i=L.front();i!=L.end();++i)
{
cout<<*i<<" ";
}
return 0;
}