mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
StringRef appends itself to std::string efficiently
This commit is contained in:
parent
cf4b7eead9
commit
950ccf4749
@ -65,9 +65,9 @@ namespace Catch {
|
|||||||
expr = m_info.capturedExpression;
|
expr = m_info.capturedExpression;
|
||||||
else {
|
else {
|
||||||
expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 );
|
expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 );
|
||||||
expr += m_info.macroName.c_str();
|
expr += m_info.macroName;
|
||||||
expr += "( ";
|
expr += "( ";
|
||||||
expr += m_info.capturedExpression.c_str();
|
expr += m_info.capturedExpression;
|
||||||
expr += " )";
|
expr += " )";
|
||||||
}
|
}
|
||||||
return expr;
|
return expr;
|
||||||
|
@ -115,6 +115,11 @@ namespace Catch {
|
|||||||
return os.write(str.m_start, str.m_size);
|
return os.write(str.m_start, str.m_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto operator+=( std::string& lhs, StringRef const& rhs ) -> std::string& {
|
||||||
|
lhs.append(rhs.m_start, rhs.m_size);
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
@ -92,6 +92,8 @@ namespace Catch {
|
|||||||
|
|
||||||
auto operator[] ( size_type index ) const noexcept -> char;
|
auto operator[] ( size_type index ) const noexcept -> char;
|
||||||
|
|
||||||
|
friend auto operator += ( std::string& lhs, StringRef const& rhs ) -> std::string&;
|
||||||
|
|
||||||
public: // named queries
|
public: // named queries
|
||||||
auto empty() const noexcept -> bool {
|
auto empty() const noexcept -> bool {
|
||||||
return m_size == 0;
|
return m_size == 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user