Skip to content

Commit cb6d713

Browse files
committed
Add lifetimebound annotation to StringRef
1 parent 8e4ab5d commit cb6d713

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/catch2/internal/catch_stringref.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
#ifndef CATCH_STRINGREF_HPP_INCLUDED
99
#define CATCH_STRINGREF_HPP_INCLUDED
1010

11+
#include <catch2/internal/catch_lifetimebound.hpp>
12+
1113
#include <cstddef>
1214
#include <string>
1315
#include <iosfwd>
1416
#include <cassert>
15-
1617
#include <cstring>
1718

1819
namespace Catch {
@@ -36,14 +37,16 @@ namespace Catch {
3637
public: // construction
3738
constexpr StringRef() noexcept = default;
3839

39-
StringRef( char const* rawChars ) noexcept;
40+
StringRef( char const* rawChars CATCH_ATTR_LIFETIMEBOUND ) noexcept;
4041

41-
constexpr StringRef( char const* rawChars, size_type size ) noexcept
42+
constexpr StringRef( char const* rawChars CATCH_ATTR_LIFETIMEBOUND,
43+
size_type size ) noexcept
4244
: m_start( rawChars ),
4345
m_size( size )
4446
{}
4547

46-
StringRef( std::string const& stdString ) noexcept
48+
StringRef(
49+
std::string const& stdString CATCH_ATTR_LIFETIMEBOUND ) noexcept
4750
: m_start( stdString.c_str() ),
4851
m_size( stdString.size() )
4952
{}
@@ -89,7 +92,7 @@ namespace Catch {
8992
}
9093

9194
// Returns the current start pointer. May not be null-terminated.
92-
constexpr char const* data() const noexcept {
95+
constexpr char const* data() const noexcept CATCH_ATTR_LIFETIMEBOUND {
9396
return m_start;
9497
}
9598

0 commit comments

Comments
 (0)