diff --git a/src/catch2/internal/catch_message_info.hpp b/src/catch2/internal/catch_message_info.hpp index 1ef43fda..ded098f5 100644 --- a/src/catch2/internal/catch_message_info.hpp +++ b/src/catch2/internal/catch_message_info.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED #define CATCH_MESSAGE_INFO_HPP_INCLUDED +#include #include #include #include @@ -27,9 +28,11 @@ namespace Catch { ResultWas::OfType type; unsigned int sequence; + DEPRECATED( "Explicitly use the 'sequence' member instead" ) bool operator == (MessageInfo const& other) const { return sequence == other.sequence; } + DEPRECATED( "Explicitly use the 'sequence' member instead" ) bool operator < (MessageInfo const& other) const { return sequence < other.sequence; } diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index ae170d1f..a6b99c02 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -439,8 +439,14 @@ namespace Catch { m_messages.push_back(message); } - void RunContext::popScopedMessage(MessageInfo const & message) { - m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end()); + void RunContext::popScopedMessage( MessageInfo const& message ) { + m_messages.erase( + std::remove_if( m_messages.begin(), + m_messages.end(), + [id = message.sequence]( MessageInfo const& msg ) { + return msg.sequence == id; + } ), + m_messages.end() ); } void RunContext::emplaceUnscopedMessage( MessageBuilder&& builder ) {