Skip to content

Commit bcdd786

Browse files
Bug, StringView !=重载逻辑错误
1 parent b1c2868 commit bcdd786

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

include/YY/Base/Containers/Span.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,20 @@ namespace YY
578578
return true;
579579
}
580580

581+
bool __YYAPI operator!=(_In_ const Span& _Other) const
582+
{
583+
if (GetLength() != _Other.GetLength())
584+
return true;
585+
586+
for (size_t i = 0; i < GetLength(); ++i)
587+
{
588+
if (pData[i] == _Other.pData[i])
589+
return true;
590+
}
591+
592+
return false;
593+
}
594+
581595
_Type* __YYAPI begin() noexcept
582596
{
583597
return pData;

include/YY/Base/Strings/String.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,16 +657,16 @@ namespace YY
657657

658658
bool __YYAPI operator!=(const StringBase& _szSrc) const
659659
{
660-
if (this->GetSize() == _szSrc.GetSize())
661-
return false;
660+
if (this->GetSize() != _szSrc.GetSize())
661+
return true;
662662

663663
return memcmp(this->GetConstString(), _szSrc.GetConstString(), this->GetSize() * sizeof(char_t)) != 0;
664664
}
665665

666666
bool __YYAPI operator!=(const StringView& _szSrc) const
667667
{
668-
if (this->GetSize() == _szSrc.GetSize())
669-
return false;
668+
if (this->GetSize() != _szSrc.GetSize())
669+
return true;
670670

671671
return memcmp(this->GetConstString(), _szSrc.GetConstString(), this->GetSize() * sizeof(char_t)) != 0;
672672
}

include/YY/Base/Strings/StringView.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ namespace YY
139139

140140
bool __YYAPI operator!=(StringView _sOther) const
141141
{
142-
if (cchString == _sOther.cchString)
143-
return false;
142+
if (cchString != _sOther.cchString)
143+
return true;
144144

145145
return memcmp(sString, _sOther.sString, cchString * sizeof(sString[0])) != 0;
146146
}
@@ -860,8 +860,8 @@ namespace YY
860860

861861
bool __YYAPI operator!=(StringView _sOther) const
862862
{
863-
if (cchString == _sOther.cchString)
864-
return false;
863+
if (cchString != _sOther.cchString)
864+
return true;
865865

866866
return memcmp(sString, _sOther.sString, cchString * sizeof(sString[0])) != 0;
867867
}

0 commit comments

Comments
 (0)