In the 1st code snippet below, I am trying to remove an element from a vector within a member function based on a static condition function fed into std::remove_if function. My problem here is that the input parameter uuid in removeVipAddress method cannot accessed within the condition function. What do you think I should do here to enable removal of an item from the vector based on the input parameter named uuid? Thanks. NOte: This is a follow up problem explained previously in Removing an item from an 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_if(
mVipAddressList.begin(),
mVipAddressList.end(),
RemoveCond::condition);
mVipAddressList.erase(last, mVipAddressList.end());
}
SNIPPET 2 (COMPILATION OUTPUT)
$ g++ -g -c -std=c++11 -Wall Entity.hpp
Entity.hpp: In static member function ‘static bool ECLBCP::VipAddressSet::removeVipAddress(std::string&)::RemoveCond::condition(const ECLBCP::VipAddressEntity&)’:
Entity.hpp:203:32: error: use of parameter from containing function
Entity.hpp:197:7: error: ‘std::string& uuid’ declared here