我想是這樣的remove_if像這樣的東西。調用的std ::名單上,其VALUE_TYPE是可移動的,但不可拷貝
std::list<MyClass> lst;
std::remove_if(lst.begin(), lst.end(), [&,this](MyClass& mcl) { return mcl.is_foo();});
海合會4.6.X,我不斷收到此錯誤:
In file included from /usr/include/c++/4.6/algorithm:63:0,
from simple_file_cache.cpp:5:
file_cache_entry.h: In function ‘_FIter std::remove_if(_FIter, _FIter, _Predicate)
[with_FIter = std::_List_iterator<MyClass>, _Predicate =
AnotherClass::foo_bar(std::tuple<unsigned int, unsigned int>)::<lambda(MyClass&)>]’:
anotherclass.cpp:225:11: instantiated from here
anotherclass.h:68:18: error: ‘MyClass& MyClass::operator=(const MyClass&)’ is private
/usr/include/c++/4.6/bits/stl_algo.h:1149:13: error: within this context
make: *** [simple_file_cache.o] Error 1
爲什麼它尋找一個拷貝構造函數?
'std :: remove'或'std :: remove_if'?您的標題和您的代碼不匹配。 –
另請注意,GCC 4.6中的C++ 11支持受到嚴重限制。 –
實際上,'std :: list'上的'std :: remove_if'對我沒有這樣的意義。我寧願使用'std :: list :: erase'或'std :: list :: remove_if'。 – dyp