diff options
| author | Martin Hořeňovský | 2020-05-10 07:22:11 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-05-10 07:22:11 +0200 |
| commit | 895d0a06960d9f48190dde7c7aa4a56d614946fc (patch) | |
| tree | 47f966785fdfb5e29bef60fb215e9fc78f184ec7 /src/catch2 | |
| parent | 094d840efe51bf1b06679d9c281e7e1513db2c81 (diff) | |
| download | catch3-895d0a06960d9f48190dde7c7aa4a56d614946fc.tar.gz | |
Small improvements for StringRef
* `operator[]` is constexpr
* `operator<<` and `operator+=` are hidden friends
Diffstat (limited to 'src/catch2')
| -rw-r--r-- | src/catch2/catch_stringref.hpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/catch2/catch_stringref.hpp b/src/catch2/catch_stringref.hpp index 8ed1e731..1e07b6ad 100644 --- a/src/catch2/catch_stringref.hpp +++ b/src/catch2/catch_stringref.hpp @@ -53,7 +53,7 @@ namespace Catch { return !(*this == other); } - auto operator[] ( size_type index ) const noexcept -> char { + constexpr auto operator[] ( size_type index ) const noexcept -> char { assert(index < m_size); return m_start[index]; } @@ -97,10 +97,12 @@ namespace Catch { public: // iterators constexpr const_iterator begin() const { return m_start; } 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); }; - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; - auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { return StringRef( rawChars, size ); |