В приведенном ниже фрагменте кода я пытаюсь удалить элемент из вектора внутри функции-члена на основе функции статического условия, введенной в функцию std :: remove. Затем я получаю много ошибок шаблонов, показанных во втором фрагменте. Не могли бы вы рассказать мне, что мне не хватает?Удаление элемента из std :: vector
SNIPPET 1 (КОД)
void removeVipAddress(std::string &uuid)
{
struct RemoveCond
{
static bool condition(const VipAddressEntity & o)
{
return o.getUUID() == uuid;
}
};
std::vector<VipAddressEntity>::iterator last =
std::remove(
mVipAddressList.begin(),
mVipAddressList.end(),
RemoveCond::condition);
mVipAddressList.erase(last, mVipAddressList.end());
}
SNIPPET 2 (СБОР ВЫХОД)
/usr/include/c++/4.7/bits/random.h:4845:5: note: template<class _IntType> bool std::operator==(const std::discrete_distribution<_IntType>&, const std::discrete_distribution<_IntType>&)
/usr/include/c++/4.7/bits/random.h:4845:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.7/algorithm:63:0,
from Entity.hpp:12:
/usr/include/c++/4.7/bits/stl_algo.h:174:4: note: ‘ECLBCP::VipAddressEntity’ is not derived from ‘const std::discrete_distribution<_IntType>’
In file included from /usr/include/c++/4.7/random:50:0,
from /usr/include/c++/4.7/bits/stl_algo.h:67,
from /usr/include/c++/4.7/algorithm:63,
from Entity.hpp:12:
/usr/include/c++/4.7/bits/random.h:4613:5: note: template<class _RealType> bool std::operator==(const std::extreme_value_distribution<_RealType>&, const std::extreme_value_distribution<_RealType>&)
/usr/include/c++/4.7/bits/random.h:4613:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.7/algorithm:63:0,
from Entity.hpp:12:
/usr/include/c++/4.7/bits/stl_algo.h:174:4: note: ‘ECLBCP::VipAddressEntity’ is not derived from ‘const std::extreme_value_distribution<_RealType>’
Это только часть примечаний об ошибке, настоящая ошибка отсутствует. – PlasmaHH
Насколько я знаю, вы не можете использовать RemoveCond :: condition в качестве аргумента шаблона здесь. Взгляните на http://stackoverflow.com/a/7627218/767543, где «однако это не разрешено, f не может быть передано функции шаблона в C++ 03». говорится. Возможно, я ошибаюсь –
У меня появилось так много сообщений об ошибках, которые не могли вписаться в буфер терминала ... –