diff options
| author | Martin Hořeňovský | 2025-10-04 16:12:17 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2025-10-04 16:12:17 +0200 |
| commit | cb6d713774d66e2f63c5378fd1b7faaa7eddf956 (patch) | |
| tree | 6d5114bdf8390adb9d0c6c349e3bb8f419ae7a94 | |
| parent | 8e4ab5dd8f5a9b6fed373c58a9aa07a82e528827 (diff) | |
| download | catch3-cb6d713774d66e2f63c5378fd1b7faaa7eddf956.tar.gz | |
Add lifetimebound annotation to StringRef
| -rw-r--r-- | src/catch2/internal/catch_stringref.hpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/catch2/internal/catch_stringref.hpp b/src/catch2/internal/catch_stringref.hpp index 421ce712..e70925bc 100644 --- a/src/catch2/internal/catch_stringref.hpp +++ b/src/catch2/internal/catch_stringref.hpp @@ -8,11 +8,12 @@ #ifndef CATCH_STRINGREF_HPP_INCLUDED #define CATCH_STRINGREF_HPP_INCLUDED +#include <catch2/internal/catch_lifetimebound.hpp> + #include <cstddef> #include <string> #include <iosfwd> #include <cassert> - #include <cstring> namespace Catch { @@ -36,14 +37,16 @@ namespace Catch { public: // construction constexpr StringRef() noexcept = default; - StringRef( char const* rawChars ) noexcept; + StringRef( char const* rawChars CATCH_ATTR_LIFETIMEBOUND ) noexcept; - constexpr StringRef( char const* rawChars, size_type size ) noexcept + constexpr StringRef( char const* rawChars CATCH_ATTR_LIFETIMEBOUND, + size_type size ) noexcept : m_start( rawChars ), m_size( size ) {} - StringRef( std::string const& stdString ) noexcept + StringRef( + std::string const& stdString CATCH_ATTR_LIFETIMEBOUND ) noexcept : m_start( stdString.c_str() ), m_size( stdString.size() ) {} @@ -89,7 +92,7 @@ namespace Catch { } // Returns the current start pointer. May not be null-terminated. - constexpr char const* data() const noexcept { + constexpr char const* data() const noexcept CATCH_ATTR_LIFETIMEBOUND { return m_start; } |