Skip to content

Commit 9b6911a

Browse files
committed
Fix: Missing span::operator==0 for new NVCC benchamrks
1 parent 908d7f9 commit 9b6911a

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

include/stringzilla/types.hpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ struct span<value_type_, SZ_SIZE_MAX> {
230230

231231
constexpr span() noexcept = default;
232232
constexpr span(value_type *data, size_type size) noexcept : data_(data), size_(size) {}
233-
constexpr span(value_type *data, value_type *end) noexcept : data_(data), size_(static_cast<size_type>(end - data)) {}
233+
constexpr span(value_type *data, value_type *end) noexcept
234+
: data_(data), size_(static_cast<size_type>(end - data)) {}
234235

235236
sz_constexpr_if_cpp14 explicit operator bool() const noexcept { return data_ != nullptr; }
236237

@@ -261,6 +262,27 @@ struct span<value_type_, SZ_SIZE_MAX> {
261262
sz_assert_(offset + count <= size_ && "Subspan out of bounds");
262263
return span(data_ + offset, count);
263264
}
265+
266+
/// @brief Lexicographic equality comparison for STL compatibility.
267+
sz_constexpr_if_cpp14 bool operator==(span const &other) const noexcept {
268+
if (size_ != other.size_) return false;
269+
for (size_type i = 0; i < size_; ++i)
270+
if (data_[i] != other.data_[i]) return false;
271+
return true;
272+
}
273+
274+
/// @brief Lexicographic inequality comparison for STL compatibility.
275+
sz_constexpr_if_cpp14 bool operator!=(span const &other) const noexcept { return !(*this == other); }
276+
277+
/// @brief Lexicographic less-than comparison for STL compatibility.
278+
sz_constexpr_if_cpp14 bool operator<(span const &other) const noexcept {
279+
size_type const min_size = size_ < other.size_ ? size_ : other.size_;
280+
for (size_type i = 0; i < min_size; ++i) {
281+
if (data_[i] < other.data_[i]) return true;
282+
if (data_[i] > other.data_[i]) return false;
283+
}
284+
return size_ < other.size_;
285+
}
264286
};
265287

266288
template <std::size_t extent_, typename value_type_>
@@ -784,7 +806,9 @@ struct gpu_specs_t {
784806
* - 9.0 is Hopper, like H100 - maps to 90
785807
* - 12.0, 12.1 is Blackwell, like B200 - maps to 120, 121
786808
*/
787-
inline static size_t pack_sm_code(int major, int minor) noexcept { return static_cast<size_t>((major * 10) + minor); }
809+
inline static size_t pack_sm_code(int major, int minor) noexcept {
810+
return static_cast<size_t>((major * 10) + minor);
811+
}
788812

789813
/**
790814
* @brief Looks up hardware specs for a given compute capability (major, minor).

0 commit comments

Comments
 (0)