summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/irc/irc_channel.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/irc/irc_channel.cpp b/src/irc/irc_channel.cpp
index 9801513..e769245 100644
--- a/src/irc/irc_channel.cpp
+++ b/src/irc/irc_channel.cpp
@@ -37,11 +37,14 @@ IrcUser* IrcChannel::find_user(const std::string& name) const
void IrcChannel::remove_user(const IrcUser* user)
{
- this->users.erase(std::remove_if(this->users.begin(), this->users.end(),
- [user](const std::unique_ptr<IrcUser>& u)
- {
- return user->nick == u->nick;
- }), this->users.end());
+ const auto nick = user->nick;
+ const auto it = std::find_if(this->users.begin(), this->users.end(),
+ [nick](const std::unique_ptr<IrcUser>& u)
+ {
+ return nick == u->nick;
+ });
+ if (it != this->users.end())
+ this->users.erase(it);
}
void IrcChannel::remove_all_users()