From b2aca61894242f1fdc027c5da6cec883dbf10cc5 Mon Sep 17 00:00:00 2001 From: Sebastian Mach Date: Mon, 9 Sep 2013 15:13:48 +0200 Subject: [PATCH] fix missing operator== by using a member predicate instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On at least one compiler (g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54)), including catch.hpp yields multiple `no match for ‘operator==’ in ‘__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Catch::Ptr*, _Container = std::vector, std::allocator > >]() == __val’`. This commit fixes the issue by replacing the friend comparison operator with a functor. --- include/internal/catch_interfaces_reporter.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 1de4778e..8d44b408 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -303,9 +303,14 @@ namespace Catch std::string stdOut; std::string stdErr; }; - friend bool operator == ( Ptr const& node, SectionInfo const& other ) { - return node->stats.sectionInfo.lineInfo == other.lineInfo; - } + struct BySectionInfo { + BySectionInfo( SectionInfo const& other ) : other( other ) {} + bool operator() ( Ptr const& node ) const { + return node->stats.sectionInfo.lineInfo == other.lineInfo; + } + private: + SectionInfo const& other; + }; typedef Node TestCaseNode; typedef Node TestGroupNode; @@ -333,7 +338,8 @@ namespace Catch else { SectionNode& parentNode = *m_sectionStack.back(); SectionNode::ChildSections::const_iterator it = - std::find( parentNode.childSections.begin(), parentNode.childSections.end(), sectionInfo ); + std::find_if( parentNode.childSections.begin(), parentNode.childSections.end(), + BySectionInfo(sectionInfo) ); if( it == parentNode.childSections.end() ) { node = new SectionNode( incompleteStats ); parentNode.childSections.push_back( node );