Deprecate comparison operators on MessageInfo

This commit is contained in:
Martin Hořeňovský
2025-07-21 11:53:00 +02:00
parent 8c3ffe05e1
commit 98b4bbb35e
2 changed files with 11 additions and 2 deletions

View File

@@ -8,6 +8,7 @@
#ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED
#define CATCH_MESSAGE_INFO_HPP_INCLUDED
#include <catch2/internal/catch_deprecation_macro.hpp>
#include <catch2/internal/catch_result_type.hpp>
#include <catch2/internal/catch_source_line_info.hpp>
#include <catch2/internal/catch_stringref.hpp>
@@ -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;
}

View File

@@ -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 ) {