Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2025-10-04 16:38:07 +0200
committerMartin Hořeňovský2025-10-04 16:38:07 +0200
commit363ca5af1816f2a03cf0815f916fe70fed19ba27 (patch)
tree7eb2b8111a7d1c86670ae7bda54937d186db45be
parentcb6d713774d66e2f63c5378fd1b7faaa7eddf956 (diff)
downloadcatch3-363ca5af1816f2a03cf0815f916fe70fed19ba27.tar.gz
Add lifetime annotations to more places using StringRef
-rw-r--r--src/catch2/internal/catch_string_manip.hpp7
-rw-r--r--src/catch2/internal/catch_test_case_tracker.hpp3
2 files changed, 6 insertions, 4 deletions
diff --git a/src/catch2/internal/catch_string_manip.hpp b/src/catch2/internal/catch_string_manip.hpp
index dc0c552c..4251f83d 100644
--- a/src/catch2/internal/catch_string_manip.hpp
+++ b/src/catch2/internal/catch_string_manip.hpp
@@ -8,6 +8,7 @@
#ifndef CATCH_STRING_MANIP_HPP_INCLUDED
#define CATCH_STRING_MANIP_HPP_INCLUDED
+#include <catch2/internal/catch_lifetimebound.hpp>
#include <catch2/internal/catch_stringref.hpp>
#include <cstdint>
@@ -28,10 +29,10 @@ namespace Catch {
//! Returns a new string without whitespace at the start/end
std::string trim( std::string const& str );
//! Returns a substring of the original ref without whitespace. Beware lifetimes!
- StringRef trim(StringRef ref);
+ StringRef trim( StringRef ref CATCH_ATTR_LIFETIMEBOUND );
// !!! Be aware, returns refs into original string - make sure original string outlives them
- std::vector<StringRef> splitStringRef( StringRef str, char delimiter );
+ std::vector<StringRef> splitStringRef( StringRef str CATCH_ATTR_LIFETIMEBOUND, char delimiter );
bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );
/**
@@ -49,7 +50,7 @@ namespace Catch {
StringRef m_label;
public:
- constexpr pluralise(std::uint64_t count, StringRef label):
+ constexpr pluralise(std::uint64_t count, StringRef label CATCH_ATTR_LIFETIMEBOUND):
m_count(count),
m_label(label)
{}
diff --git a/src/catch2/internal/catch_test_case_tracker.hpp b/src/catch2/internal/catch_test_case_tracker.hpp
index 50278c91..6bd749ff 100644
--- a/src/catch2/internal/catch_test_case_tracker.hpp
+++ b/src/catch2/internal/catch_test_case_tracker.hpp
@@ -8,6 +8,7 @@
#ifndef CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
#define CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
+#include <catch2/internal/catch_lifetimebound.hpp>
#include <catch2/internal/catch_source_line_info.hpp>
#include <catch2/internal/catch_unique_ptr.hpp>
#include <catch2/internal/catch_stringref.hpp>
@@ -48,7 +49,7 @@ namespace TestCaseTracking {
StringRef name;
SourceLineInfo location;
- constexpr NameAndLocationRef( StringRef name_,
+ constexpr NameAndLocationRef( StringRef name_ CATCH_ATTR_LIFETIMEBOUND,
SourceLineInfo location_ ):
name( name_ ), location( location_ ) {}