mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-23 05:46:11 +01:00
Reinline some StringRef methods with trivial bodies
This commit is contained in:
parent
dab0296b64
commit
a156440b19
@ -22,10 +22,6 @@ namespace Catch {
|
|||||||
: StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) )
|
: StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
StringRef::operator std::string() const {
|
|
||||||
return std::string( m_start, m_size );
|
|
||||||
}
|
|
||||||
|
|
||||||
void StringRef::swap( StringRef& other ) noexcept {
|
void StringRef::swap( StringRef& other ) noexcept {
|
||||||
std::swap( m_start, other.m_start );
|
std::swap( m_start, other.m_start );
|
||||||
std::swap( m_size, other.m_size );
|
std::swap( m_size, other.m_size );
|
||||||
@ -72,10 +68,6 @@ namespace Catch {
|
|||||||
return !operator==( other );
|
return !operator==( other );
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StringRef::operator[](size_type index) const noexcept -> char {
|
|
||||||
return m_start[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& {
|
auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& {
|
||||||
return os.write(str.currentData(), str.size());
|
return os.write(str.currentData(), str.size());
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@ -79,7 +80,9 @@ namespace Catch {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator std::string() const;
|
explicit operator std::string() const {
|
||||||
|
return std::string(m_start, m_size);
|
||||||
|
}
|
||||||
|
|
||||||
void swap( StringRef& other ) noexcept;
|
void swap( StringRef& other ) noexcept;
|
||||||
|
|
||||||
@ -87,7 +90,10 @@ namespace Catch {
|
|||||||
auto operator == ( StringRef const& other ) const noexcept -> bool;
|
auto operator == ( StringRef const& other ) const noexcept -> bool;
|
||||||
auto operator != ( StringRef const& other ) const noexcept -> bool;
|
auto operator != ( StringRef const& other ) const noexcept -> bool;
|
||||||
|
|
||||||
auto operator[] ( size_type index ) const noexcept -> char;
|
auto operator[] ( size_type index ) const noexcept -> char {
|
||||||
|
assert(index < m_size);
|
||||||
|
return m_start[index];
|
||||||
|
}
|
||||||
|
|
||||||
public: // named queries
|
public: // named queries
|
||||||
auto empty() const noexcept -> bool {
|
auto empty() const noexcept -> bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user