diff --git a/sycl/include/sycl/detail/string_view.hpp b/sycl/include/sycl/detail/string_view.hpp index a4e1c0bf20436..d394de736d847 100644 --- a/sycl/include/sycl/detail/string_view.hpp +++ b/sycl/include/sycl/detail/string_view.hpp @@ -68,51 +68,15 @@ class string_view { constexpr const char *data() const noexcept { return str ? str : ""; } - constexpr explicit operator std::string_view() const noexcept { + constexpr operator std::string_view() const noexcept { + if (str == nullptr) + return std::string_view{}; #ifdef __INTEL_PREVIEW_BREAKING_CHANGES return std::string_view(str, len); #else return std::string_view(str); #endif } - -#ifdef __INTEL_PREVIEW_BREAKING_CHANGES - friend constexpr bool operator==(string_view lhs, - std::string_view rhs) noexcept { - return rhs == std::string_view(lhs); - } - friend constexpr bool operator==(std::string_view lhs, - string_view rhs) noexcept { - return lhs == std::string_view(rhs); - } - - friend constexpr bool operator!=(string_view lhs, - std::string_view rhs) noexcept { - return rhs != std::string_view(lhs); - } - friend constexpr bool operator!=(std::string_view lhs, - string_view rhs) noexcept { - return lhs != std::string_view(rhs); - } -#else - friend constexpr bool operator==(string_view lhs, - std::string_view rhs) noexcept { - return rhs == lhs.data(); - } - friend constexpr bool operator==(std::string_view lhs, - string_view rhs) noexcept { - return lhs == rhs.data(); - } - - friend constexpr bool operator!=(string_view lhs, - std::string_view rhs) noexcept { - return rhs != lhs.data(); - } - friend constexpr bool operator!=(std::string_view lhs, - string_view rhs) noexcept { - return lhs != rhs.data(); - } -#endif }; } // namespace detail