本文介绍了帮助我理解std :: erase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C ++ In A Nutshell一书中,有以下示例代码
In the book 'C++ In A Nutshell', there is the following example code
std::vector<int> data
...
std::erase(std::remove(data.begin(), data.end(), 42),
data.end());
我认为'erase'是一个成员函数,所以不应该是'data.erase '而不是'std :: erase'?
是否有一些方法c ++编译器可以告诉你要调用成员函数的成员,或者书是否省略了擦除模板函数的任何文档,还是示例错了?
I thought that 'erase' was a member function, so shouldn't that be 'data.erase' rather than 'std::erase'?Is there some way the c++ compiler can tell what member you wanted to call a member function on, or did the book omit any documentation of an erase template function, or is the example wrong?
推荐答案
erase
是一个成员函数。提供的示例不正确。
erase
is a member function. The sample provided is incorrect.
这篇关于帮助我理解std :: erase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!