From 8a9aaaffa651241e4ea203b09d542d568a16e71d Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Mon, 5 Feb 2024 15:56:17 -0800 Subject: [PATCH] pass std::string_view by value Signed-off-by: Byoungro So --- sycl/include/sycl/detail/string.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sycl/include/sycl/detail/string.hpp b/sycl/include/sycl/detail/string.hpp index 9844e2cb25c81..4c9bf72e025ec 100644 --- a/sycl/include/sycl/detail/string.hpp +++ b/sycl/include/sycl/detail/string.hpp @@ -25,7 +25,7 @@ class string { string() noexcept = default; ~string() { delete[] str; } - string(const std::string_view &strn) { + string(const std::string_view strn) { size_t len = strn.length(); str = new char[len + 1]; strn.copy(str, len); @@ -52,7 +52,7 @@ class string { return *this; } - string &operator=(const std::string_view &strn) { + string &operator=(const std::string_view strn) { *this = string{strn}; return *this; } @@ -60,10 +60,10 @@ class string { const char *c_str() const noexcept { return str; } friend bool operator==(const string &lhs, - const std::string_view &rhs) noexcept { + const std::string_view rhs) noexcept { return rhs == lhs.c_str(); } - friend bool operator==(const std::string_view &lhs, + friend bool operator==(const std::string_view lhs, const string &rhs) noexcept { return lhs == rhs.c_str(); }