mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-16 18:52:25 +01:00
fix missing operator== by using a member predicate instead
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<Catch::CumulativeReporterBase::SectionNode>*, _Container = std::vector<Catch::Ptr<Catch::CumulativeReporterBase::SectionNode>, std::allocator<Catch::Ptr<Catch::CumulativeReporterBase::SectionNode> > >]() == __val’`. This commit fixes the issue by replacing the friend comparison operator with a functor.
This commit is contained in:
parent
f7378eebb6
commit
b2aca61894
@ -303,9 +303,14 @@ namespace Catch
|
|||||||
std::string stdOut;
|
std::string stdOut;
|
||||||
std::string stdErr;
|
std::string stdErr;
|
||||||
};
|
};
|
||||||
friend bool operator == ( Ptr<SectionNode> const& node, SectionInfo const& other ) {
|
struct BySectionInfo {
|
||||||
return node->stats.sectionInfo.lineInfo == other.lineInfo;
|
BySectionInfo( SectionInfo const& other ) : other( other ) {}
|
||||||
}
|
bool operator() ( Ptr<SectionNode> const& node ) const {
|
||||||
|
return node->stats.sectionInfo.lineInfo == other.lineInfo;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
SectionInfo const& other;
|
||||||
|
};
|
||||||
|
|
||||||
typedef Node<TestCaseStats, SectionNode> TestCaseNode;
|
typedef Node<TestCaseStats, SectionNode> TestCaseNode;
|
||||||
typedef Node<TestGroupStats, TestCaseNode> TestGroupNode;
|
typedef Node<TestGroupStats, TestCaseNode> TestGroupNode;
|
||||||
@ -333,7 +338,8 @@ namespace Catch
|
|||||||
else {
|
else {
|
||||||
SectionNode& parentNode = *m_sectionStack.back();
|
SectionNode& parentNode = *m_sectionStack.back();
|
||||||
SectionNode::ChildSections::const_iterator it =
|
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() ) {
|
if( it == parentNode.childSections.end() ) {
|
||||||
node = new SectionNode( incompleteStats );
|
node = new SectionNode( incompleteStats );
|
||||||
parentNode.childSections.push_back( node );
|
parentNode.childSections.push_back( node );
|
||||||
|
Loading…
Reference in New Issue
Block a user