아래의 첫 번째 코드 단편에서는 std :: remove 함수로 제공되는 정적 조건 함수를 기반으로 멤버 함수 내에서 벡터에서 요소를 제거하려고합니다. 그런 다음 제 2 스 니펫에 표시된 템플릿 오류가 많이 발생합니다. 제가 누락 된 부분을 말씀해 주시겠습니까?std :: vector에서 항목 제거
SNIPPET 1 (CODE)
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 (컴파일 OUTPUT)
/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을 템플릿 arguement로 사용할 수 없습니다. http://stackoverflow.com/a/7627218/767543에서 "이것은 허용되지 않지만 f는 C++ 03의 템플릿 함수에 전달 될 수 없습니다." 라고 명시되어 있습니다. 비록 내가 틀릴 수도있다. –
나는 터미널의 버퍼에 맞지 않는 많은 에러 메시지를 가지고있다. –