Update equality overloads for C++20
C++20 added new reverse and rewritten candidates. This can confuse the compiler because it'll test both A==B and B==A for overloads. Because we were defining parent class equality overloads, A==B and B==A was considered ambigious due to both being compatible in casting. So we needed to add explicit child class equality operator overloads
This commit is contained in:
parent
7a67151a22
commit
96cdfc7fa7
|
@ -1321,6 +1321,7 @@ bool SCH_FIELD::operator <( const SCH_ITEM& aItem ) const
|
|||
return GetName() < field->GetName();
|
||||
}
|
||||
|
||||
|
||||
bool SCH_FIELD::operator==(const SCH_ITEM& aOther) const
|
||||
{
|
||||
if( Type() != aOther.Type() )
|
||||
|
@ -1328,22 +1329,28 @@ bool SCH_FIELD::operator==( const SCH_ITEM& aOther ) const
|
|||
|
||||
const SCH_FIELD& field = static_cast<const SCH_FIELD&>( aOther );
|
||||
|
||||
if( GetId() != field.GetId() )
|
||||
return *this == field;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_FIELD::operator==( const SCH_FIELD& aOther ) const
|
||||
{
|
||||
if( GetId() != aOther.GetId() )
|
||||
return false;
|
||||
|
||||
if( GetPosition() != field.GetPosition() )
|
||||
if( GetPosition() != aOther.GetPosition() )
|
||||
return false;
|
||||
|
||||
if( IsNamedVariable() != field.IsNamedVariable() )
|
||||
if( IsNamedVariable() != aOther.IsNamedVariable() )
|
||||
return false;
|
||||
|
||||
if( IsNameShown() != field.IsNameShown() )
|
||||
if( IsNameShown() != aOther.IsNameShown() )
|
||||
return false;
|
||||
|
||||
if( CanAutoplace() != field.CanAutoplace() )
|
||||
if( CanAutoplace() != aOther.CanAutoplace() )
|
||||
return false;
|
||||
|
||||
if( GetText() != field.GetText() )
|
||||
if( GetText() != aOther.GetText() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -284,6 +284,7 @@ public:
|
|||
double Similarity( const SCH_ITEM& aItem ) const override;
|
||||
|
||||
bool operator==( const SCH_ITEM& aItem ) const override;
|
||||
bool operator==( const SCH_FIELD& aItem ) const;
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
|
|
|
@ -165,8 +165,8 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) const
|
|||
// XML output:
|
||||
wxString s = GetClass();
|
||||
|
||||
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_pos << wxS( ", " ) << m_diameter
|
||||
<< wxS( "/>\n" );
|
||||
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_pos << ", " << m_diameter
|
||||
<< "/>\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -494,13 +494,19 @@ bool SCH_PIN::operator==( const SCH_ITEM& aOther ) const
|
|||
|
||||
const SCH_PIN& other = static_cast<const SCH_PIN&>( aOther );
|
||||
|
||||
if( m_number != other.m_number )
|
||||
return *this == other;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_PIN::operator==( const SCH_PIN& aOther ) const
|
||||
{
|
||||
if( m_number != aOther.m_number )
|
||||
return false;
|
||||
|
||||
if( m_position != other.m_position )
|
||||
if( m_position != aOther.m_position )
|
||||
return false;
|
||||
|
||||
return m_libPin == other.m_libPin;
|
||||
return m_libPin == aOther.m_libPin;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -169,6 +169,7 @@ public:
|
|||
double Similarity( const SCH_ITEM& aItem ) const override;
|
||||
|
||||
bool operator==( const SCH_ITEM& aItem ) const override;
|
||||
bool operator==( const SCH_PIN& aItem ) const;
|
||||
|
||||
bool operator!=( const SCH_PIN& aRhs ) const { return !( *this == aRhs ); }
|
||||
|
||||
|
|
|
@ -162,12 +162,15 @@ bool SCH_TABLECELL::operator==( const SCH_ITEM& aOtherItem ) const
|
|||
|
||||
const SCH_TABLECELL& other = static_cast<const SCH_TABLECELL&>( aOtherItem );
|
||||
|
||||
return m_colSpan == other.m_colSpan
|
||||
&& m_rowSpan == other.m_rowSpan
|
||||
&& SCH_TEXTBOX::operator==( other );
|
||||
return *this == other;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_TABLECELL::operator==( const SCH_TABLECELL& aOtherItem ) const
|
||||
{
|
||||
return m_colSpan == aOtherItem.m_colSpan && m_rowSpan == aOtherItem.m_rowSpan
|
||||
&& SCH_TEXTBOX::operator==( aOtherItem );
|
||||
}
|
||||
|
||||
static struct SCH_TABLECELL_DESC
|
||||
{
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
|
||||
double Similarity( const SCH_ITEM& aOther ) const override;
|
||||
|
||||
bool operator==( const SCH_TABLECELL& aOther ) const;
|
||||
bool operator==( const SCH_ITEM& aOther ) const override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -3312,39 +3312,45 @@ bool FOOTPRINT::operator==( const BOARD_ITEM& aOther ) const
|
|||
|
||||
const FOOTPRINT& other = static_cast<const FOOTPRINT&>( aOther );
|
||||
|
||||
if( m_pads.size() != other.m_pads.size() )
|
||||
return *this == other;
|
||||
}
|
||||
|
||||
|
||||
bool FOOTPRINT::operator==( const FOOTPRINT& aOther ) const
|
||||
{
|
||||
if( m_pads.size() != aOther.m_pads.size() )
|
||||
return false;
|
||||
|
||||
for( size_t ii = 0; ii < m_pads.size(); ++ii )
|
||||
{
|
||||
if( !( *m_pads[ii] == *other.m_pads[ii] ) )
|
||||
if( !( *m_pads[ii] == *aOther.m_pads[ii] ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( m_drawings.size() != other.m_drawings.size() )
|
||||
if( m_drawings.size() != aOther.m_drawings.size() )
|
||||
return false;
|
||||
|
||||
for( size_t ii = 0; ii < m_drawings.size(); ++ii )
|
||||
{
|
||||
if( !( *m_drawings[ii] == *other.m_drawings[ii] ) )
|
||||
if( !( *m_drawings[ii] == *aOther.m_drawings[ii] ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( m_zones.size() != other.m_zones.size() )
|
||||
if( m_zones.size() != aOther.m_zones.size() )
|
||||
return false;
|
||||
|
||||
for( size_t ii = 0; ii < m_zones.size(); ++ii )
|
||||
{
|
||||
if( !( *m_zones[ii] == *other.m_zones[ii] ) )
|
||||
if( !( *m_zones[ii] == *aOther.m_zones[ii] ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( m_fields.size() != other.m_fields.size() )
|
||||
if( m_fields.size() != aOther.m_fields.size() )
|
||||
return false;
|
||||
|
||||
for( size_t ii = 0; ii < m_fields.size(); ++ii )
|
||||
{
|
||||
if( !( *m_fields[ii] == *other.m_fields[ii] ) )
|
||||
if( !( *m_fields[ii] == *aOther.m_fields[ii] ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -958,6 +958,7 @@ public:
|
|||
double Similarity( const BOARD_ITEM& aOther ) const override;
|
||||
|
||||
bool operator==( const BOARD_ITEM& aOther ) const override;
|
||||
bool operator==( const FOOTPRINT& aOther ) const;
|
||||
|
||||
#if defined(DEBUG)
|
||||
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
|
|
|
@ -218,7 +218,13 @@ bool PCB_FIELD::operator==( const BOARD_ITEM& aOther ) const
|
|||
|
||||
const PCB_FIELD& other = static_cast<const PCB_FIELD&>( aOther );
|
||||
|
||||
return m_id == other.m_id && m_name == other.m_name && EDA_TEXT::operator==( other );
|
||||
return *this == other;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_FIELD::operator==( const PCB_FIELD& aOther ) const
|
||||
{
|
||||
return m_id == aOther.m_id && m_name == aOther.m_name && EDA_TEXT::operator==( aOther );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ public:
|
|||
|
||||
double Similarity( const BOARD_ITEM& aOther ) const override;
|
||||
|
||||
bool operator==( const PCB_FIELD& aOther ) const;
|
||||
bool operator==( const BOARD_ITEM& aOther ) const override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -140,7 +140,6 @@ double PCB_TABLECELL::Similarity( const BOARD_ITEM& aBoardItem ) const
|
|||
return similarity;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_TABLECELL::operator==( const BOARD_ITEM& aBoardItem ) const
|
||||
{
|
||||
if( aBoardItem.Type() != Type() )
|
||||
|
@ -148,9 +147,14 @@ bool PCB_TABLECELL::operator==( const BOARD_ITEM& aBoardItem ) const
|
|||
|
||||
const PCB_TABLECELL& other = static_cast<const PCB_TABLECELL&>( aBoardItem );
|
||||
|
||||
return m_colSpan == other.m_colSpan
|
||||
&& m_rowSpan == other.m_rowSpan
|
||||
&& PCB_TEXTBOX::operator==( other );
|
||||
return *this == other;
|
||||
}
|
||||
|
||||
bool PCB_TABLECELL::operator==( const PCB_TABLECELL& aOther ) const
|
||||
{
|
||||
return m_colSpan == aOther.m_colSpan
|
||||
&& m_rowSpan == aOther.m_rowSpan
|
||||
&& PCB_TEXTBOX::operator==( aOther );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
|
||||
double Similarity( const BOARD_ITEM& aBoardItem ) const override;
|
||||
|
||||
bool operator==( const PCB_TABLECELL& aBoardItem ) const;
|
||||
bool operator==( const BOARD_ITEM& aBoardItem ) const override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -163,8 +163,16 @@ bool PCB_TRACK::operator==( const BOARD_ITEM& aOther ) const
|
|||
|
||||
const PCB_TRACK& other = static_cast<const PCB_TRACK&>( aOther );
|
||||
|
||||
return m_Start == other.m_Start && m_End == other.m_End && m_layer == other.m_layer &&
|
||||
m_Width == other.m_Width;
|
||||
return *this == other;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_TRACK::operator==( const PCB_TRACK& aOther ) const
|
||||
{
|
||||
return m_Start == aOther.m_Start
|
||||
&& m_End == aOther.m_End
|
||||
&& m_layer == aOther.m_layer
|
||||
&& m_Width == aOther.m_Width;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -244,6 +244,7 @@ public:
|
|||
virtual double Similarity( const BOARD_ITEM& aOther ) const override;
|
||||
|
||||
virtual bool operator==( const BOARD_ITEM& aOther ) const override;
|
||||
virtual bool operator==( const PCB_TRACK& aOther ) const;
|
||||
|
||||
/**
|
||||
* Set the cached scale.
|
||||
|
|
|
@ -1393,53 +1393,58 @@ bool ZONE::operator==( const BOARD_ITEM& aOther ) const
|
|||
return false;
|
||||
|
||||
const ZONE& other = static_cast<const ZONE&>( aOther );
|
||||
return *this == other;
|
||||
}
|
||||
|
||||
if( GetIsRuleArea() != other.GetIsRuleArea() )
|
||||
|
||||
bool ZONE::operator==( const ZONE& aOther ) const
|
||||
{
|
||||
if( GetIsRuleArea() != aOther.GetIsRuleArea() )
|
||||
return false;
|
||||
|
||||
if( GetLayerSet() != other.GetLayerSet() )
|
||||
if( GetLayerSet() != aOther.GetLayerSet() )
|
||||
return false;
|
||||
|
||||
if( GetNetCode() != other.GetNetCode() )
|
||||
if( GetNetCode() != aOther.GetNetCode() )
|
||||
return false;
|
||||
|
||||
if( GetIsRuleArea() )
|
||||
{
|
||||
if( GetDoNotAllowCopperPour() != other.GetDoNotAllowCopperPour() )
|
||||
if( GetDoNotAllowCopperPour() != aOther.GetDoNotAllowCopperPour() )
|
||||
return false;
|
||||
if( GetDoNotAllowTracks() != other.GetDoNotAllowTracks() )
|
||||
if( GetDoNotAllowTracks() != aOther.GetDoNotAllowTracks() )
|
||||
return false;
|
||||
if( GetDoNotAllowVias() != other.GetDoNotAllowVias() )
|
||||
if( GetDoNotAllowVias() != aOther.GetDoNotAllowVias() )
|
||||
return false;
|
||||
if( GetDoNotAllowFootprints() != other.GetDoNotAllowFootprints() )
|
||||
if( GetDoNotAllowFootprints() != aOther.GetDoNotAllowFootprints() )
|
||||
return false;
|
||||
if( GetDoNotAllowPads() != other.GetDoNotAllowPads() )
|
||||
if( GetDoNotAllowPads() != aOther.GetDoNotAllowPads() )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( GetAssignedPriority() != other.GetAssignedPriority() )
|
||||
if( GetAssignedPriority() != aOther.GetAssignedPriority() )
|
||||
return false;
|
||||
|
||||
if( GetMinThickness() != other.GetMinThickness() )
|
||||
if( GetMinThickness() != aOther.GetMinThickness() )
|
||||
return false;
|
||||
|
||||
if( GetCornerSmoothingType() != other.GetCornerSmoothingType() )
|
||||
if( GetCornerSmoothingType() != aOther.GetCornerSmoothingType() )
|
||||
return false;
|
||||
|
||||
if( GetCornerRadius() != other.GetCornerRadius() )
|
||||
if( GetCornerRadius() != aOther.GetCornerRadius() )
|
||||
return false;
|
||||
|
||||
if( GetTeardropParams() != other.GetTeardropParams() )
|
||||
if( GetTeardropParams() != aOther.GetTeardropParams() )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( GetNumCorners() != other.GetNumCorners() )
|
||||
if( GetNumCorners() != aOther.GetNumCorners() )
|
||||
return false;
|
||||
|
||||
for( int ii = 0; ii < GetNumCorners(); ii++ )
|
||||
{
|
||||
if( GetCornerPosition( ii ) != other.GetCornerPosition( ii ) )
|
||||
if( GetCornerPosition( ii ) != aOther.GetCornerPosition( ii ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -786,6 +786,7 @@ public:
|
|||
|
||||
double Similarity( const BOARD_ITEM& aOther ) const override;
|
||||
|
||||
bool operator==( const ZONE& aOther ) const;
|
||||
bool operator==( const BOARD_ITEM& aOther ) const override;
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
|
Loading…
Reference in New Issue