Skip to content

Commit

Permalink
Cleanup StringRef impl a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
horenmar committed Nov 23, 2021
1 parent c950724 commit b9baae6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/catch2/internal/catch_stringref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ namespace Catch {
: StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) )
{}

auto StringRef::operator == ( StringRef const& other ) const noexcept -> bool {
auto StringRef::operator == ( StringRef other ) const noexcept -> bool {
return m_size == other.m_size
&& (std::memcmp( m_start, other.m_start, m_size ) == 0);
}

bool StringRef::operator<(StringRef const& rhs) const noexcept {
bool StringRef::operator<(StringRef rhs) const noexcept {
if (m_size < rhs.m_size) {
return strncmp(m_start, rhs.m_start, m_size) <= 0;
}
Expand Down Expand Up @@ -50,8 +50,8 @@ namespace Catch {
}
}

auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& {
return os.write(str.data(), str.size());
auto operator << ( std::ostream& os, StringRef str ) -> std::ostream& {
return os.write(str.data(), static_cast<std::streamsize>(str.size()));
}

std::string operator+(StringRef lhs, StringRef rhs) {
Expand All @@ -62,7 +62,7 @@ namespace Catch {
return ret;
}

auto operator+=( std::string& lhs, StringRef const& rhs ) -> std::string& {
auto operator+=( std::string& lhs, StringRef rhs ) -> std::string& {
lhs.append(rhs.data(), rhs.size());
return lhs;
}
Expand Down
10 changes: 5 additions & 5 deletions src/catch2/internal/catch_stringref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ namespace Catch {
}

public: // operators
auto operator == ( StringRef const& other ) const noexcept -> bool;
auto operator != (StringRef const& other) const noexcept -> bool {
auto operator == ( StringRef other ) const noexcept -> bool;
auto operator != (StringRef other) const noexcept -> bool {
return !(*this == other);
}

Expand All @@ -59,7 +59,7 @@ namespace Catch {
return m_start[index];
}

bool operator<(StringRef const& rhs) const noexcept;
bool operator<(StringRef rhs) const noexcept;

public: // named queries
constexpr auto empty() const noexcept -> bool {
Expand Down Expand Up @@ -90,8 +90,8 @@ namespace Catch {
constexpr const_iterator end() const { return m_start + m_size; }


friend std::string& operator += (std::string& lhs, StringRef const& sr);
friend std::ostream& operator << (std::ostream& os, StringRef const& sr);
friend std::string& operator += (std::string& lhs, StringRef sr);
friend std::ostream& operator << (std::ostream& os, StringRef sr);
friend std::string operator+(StringRef lhs, StringRef rhs);

/**
Expand Down

0 comments on commit b9baae6

Please sign in to comment.