Add more constexpr to StringRef

This commit is contained in:
Martin Hořeňovský
2020-02-13 15:01:03 +01:00
parent 63b7d6f98e
commit 2945b80f61
10 changed files with 154 additions and 41 deletions
-10
View File
@@ -22,17 +22,7 @@ namespace Catch {
CATCH_ENFORCE(isNullTerminated(), "Called StringRef::c_str() on a non-null-terminated instance");
return m_start;
}
auto StringRef::data() const noexcept -> char const* {
return m_start;
}
auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef {
if (start < m_size) {
return StringRef(m_start + start, (std::min)(m_size - start, size));
} else {
return StringRef();
}
}
auto StringRef::operator == ( StringRef const& other ) const noexcept -> bool {
return m_size == other.m_size
&& (std::memcmp( m_start, other.m_start, m_size ) == 0);