Replace stalgo::erase with C++20 std::erase.

This commit is contained in:
Sadie Powell 2024-08-25 17:17:11 +01:00
parent ab31cf9d37
commit 5dd92c5388
8 changed files with 10 additions and 28 deletions

View File

@ -86,24 +86,6 @@ namespace stdalgo
delete p;
}
/**
* Remove an element from a container
* @param cont Container to remove the element from
* @param val Value of the element to look for and remove
* @return True if the element was found and removed, false otherwise
*/
template <template<typename, typename> class Cont, typename T, typename Alloc>
inline bool erase(Cont<T, Alloc>& cont, const T& val)
{
const typename Cont<T, Alloc>::iterator it = std::find(cont.begin(), cont.end(), val);
if (it != cont.end())
{
cont.erase(it);
return true;
}
return false;
}
/**
* Check if an element with the given value is in a container. Equivalent to (std::find(cont.begin(), cont.end(), val) != cont.end()).
* @param cont Container to find the element in

View File

@ -406,7 +406,7 @@ public:
// remove their DCCALLOW list if they have one
if (udl)
stdalgo::erase(ul, user);
std::erase(ul, user);
// remove them from any DCCALLOW lists
// they are currently on

View File

@ -41,7 +41,7 @@ public:
if (change.adding)
helpers.push_back(dest);
else
stdalgo::erase(helpers, dest);
std::erase(helpers, dest);
return true;
}
@ -117,7 +117,7 @@ public:
void OnUserQuit(User* user, const std::string& message, const std::string& opermessage) override
{
if (user->IsModeSet(helpop))
stdalgo::erase(helpop.helpers, user);
std::erase(helpop.helpers, user);
}
void OnWhois(Whois::Context& whois) override

View File

@ -175,7 +175,7 @@ public:
}
// erase() not swaperase because the reftag generation logic depends on the order of the elements
stdalgo::erase(active_batches, &batch);
std::erase(active_batches, &batch);
delete batch.batchinfo;
batch.batchinfo = nullptr;
}

View File

@ -166,7 +166,7 @@ void TreeServer::FinishBurst()
void TreeServer::SQuitChild(TreeServer* server, const std::string& reason, bool error)
{
stdalgo::erase(Children, server);
std::erase(Children, server);
if (IsRoot())
{

View File

@ -193,7 +193,7 @@ ServiceProvider::ServiceProvider(Module* Creator, const std::string& Name, Servi
void ServiceProvider::DisableAutoRegister()
{
if ((ServerInstance) && (ServerInstance->Modules.NewServices))
stdalgo::erase(*ServerInstance->Modules.NewServices, this);
std::erase(*ServerInstance->Modules.NewServices, this);
}
const char* ServiceProvider::GetTypeString() const
@ -227,7 +227,7 @@ bool ModuleManager::Attach(Implementation i, Module* mod)
bool ModuleManager::Detach(Implementation i, Module* mod)
{
return stdalgo::erase(EventHandlers[i], mod);
return std::erase(EventHandlers[i], mod);
}
void ModuleManager::Attach(const Implementation* i, Module* mod, size_t sz)

View File

@ -342,7 +342,7 @@ Cullable::Result User::Cull()
ServerInstance->Users.RemoveCloneCounts(this);
if (server->IsService())
stdalgo::erase(ServerInstance->Users.all_services, this);
std::erase(ServerInstance->Users.all_services, this);
return Extensible::Cull();
}

View File

@ -357,7 +357,7 @@ bool XLineManager::DelLine(const std::string& hostmask, const std::string& type,
y->second->Unset();
stdalgo::erase(pending_lines, y->second);
std::erase(pending_lines, y->second);
delete y->second;
x->second.erase(y);
@ -456,7 +456,7 @@ void XLineManager::ExpireLine(ContainerIter container, LookupIter item, bool sil
* is pending, cleared when it is no longer pending, so we skip over this loop if its not pending?
* -- Brain
*/
stdalgo::erase(pending_lines, item->second);
std::erase(pending_lines, item->second);
delete item->second;
container->second.erase(item);