2017-06-13 87 views
-3

C++擦除刪除類型推演失敗

auto foo = [](FooPtr p) {return p->m_delete;}; 
std::deque<FooPtr> d = getD(); 
d.erase(std::remove(d.begin(), d.end(), foo), d.end()); 

,我得到的編譯錯誤爲模板實參推演/替代的大規模列表失敗:

/opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/stl_deque.h:258:5: note: template argument deduction/substitution failed: 

/opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/predefined_ops.h:191:17: note: 'std::shared_ptr<Foo>' is not derived from 'const std::deque<_Tp, _Alloc>' 
{ return *__it == _M_value; } 

/opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/predefined_ops.h:191:17: note: 'std::shared_ptr<Foo>' is not derived from 'const std::normal_distribution<_RealType>' 

/opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/predefined_ops.h:191:17: note: 'std::shared_ptr<Foo>' is not derived from 'const std::list<_Tp, _Alloc>' 
{ return *__it == _M_value; } 

這不勝枚舉久時間。任何想法我做錯了我的擦除 - 刪除?

+2

'D'檢查文檔指針,以便'D->擦除(...'沒有 – Galik

+0

'd.erase' - >提示:?'D'是一個指針 – Pixelchemist

+0

對不起,錯字d是一個指針,但我做了一些改變,因爲我認爲這可能是一個問題。它不是 – chrise

回答