Skip to content

Commit

Permalink
pass std::string_view by value
Browse files Browse the repository at this point in the history
Signed-off-by: Byoungro So <byoungro.so@intel.com>
  • Loading branch information
bso-intel committed Feb 5, 2024
1 parent e385649 commit 8a9aaaf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sycl/include/sycl/detail/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -52,18 +52,18 @@ class string {
return *this;
}

string &operator=(const std::string_view &strn) {
string &operator=(const std::string_view strn) {
*this = string{strn};
return *this;
}

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();
}
Expand Down

0 comments on commit 8a9aaaf

Please sign in to comment.