llama90 commented on code in PR #39123:
URL: https://github.com/apache/arrow/pull/39123#discussion_r1421251968


##########
cpp/src/arrow/util/span.h:
##########
@@ -129,4 +129,72 @@ constexpr span<std::byte> as_writable_bytes(span<T> s) {
   return {reinterpret_cast<std::byte*>(s.data()), s.size_bytes()};
 }
 
+template <>
+class arrow::util::span<std::byte> : public std::span<std::byte> {

Review Comment:
   I copied your code and was able to identify the following issues.
   
   `std::span` to be `span`
   
   Also, `arrow::util::span<std::byte>` case, `Explicit specialization of 
'arrow::util::span<std::byte>' after instantiation implicit instantiation first 
required here.`



##########
cpp/src/arrow/util/span.h:
##########
@@ -129,4 +129,72 @@ constexpr span<std::byte> as_writable_bytes(span<T> s) {
   return {reinterpret_cast<std::byte*>(s.data()), s.size_bytes()};
 }
 
+template <>
+class arrow::util::span<std::byte> : public std::span<std::byte> {
+ public:
+  explicit arrow::util::span(const arrow::util::span<std::byte>& other)
+      : std::span<std::byte>(other.data(), other.size()) {}
+
+  std::byte* data() const { return this->data_; }
+
+  size_t size() const { return this->size_; }
+
+  operator std::span<std::byte>() const {
+    return std::span<std::byte>(this->data_, this->size_);
+  }
+
+  bool operator==(const arrow::util::span<std::byte>& other) const {
+    return this->data_ == other.data_ && this->size_ == other.size_;
+  }
+
+  bool operator!=(const arrow::util::span<std::byte>& other) const {
+    return !(*this == other);
+  }
+};
+
+template <>
+class std::span<arrow::util::span<std::byte>> {
+ public:
+  explicit std::span(const std::span<arrow::util::span<std::byte>>& other) {
+    data_.resize(other.size());
+    size_ = other.size();
+    for (size_t i = 0; i < size_; ++i) {
+      data_[i] = arrow::util::span<std::byte>(other[i].data(), 
other[i].size());
+    }
+  }
+
+  arrow::util::span<std::byte>& operator[](size_t idx) { return data_[idx]; }
+
+  const arrow::util::span<std::byte>& operator[](size_t idx) const { return 
data_[idx]; }
+
+  arrow::util::span<std::byte>* data() const { return &data_[0]; }

Review Comment:
   `&data_[0];` case, `Cannot initialize return object of type 
'arrow::util::span<std::byte> *' with an rvalue of type 'const 
std::vector<arrow::util::span<std::byte>>::value_type *' (aka 'const 
arrow::util::span<std::byte> *')`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to