-
Notifications
You must be signed in to change notification settings - Fork 4k
GH-48588: [C++] use std::span #48615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
GH-48588: [C++] use std::span #48615
Conversation
|
|
WillAyd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
cpp/src/arrow/array/data.h
Outdated
| #include "arrow/util/bit_util.h" | ||
| #include "arrow/util/macros.h" | ||
| #include "arrow/util/span.h" | ||
| #include <span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the span include to be with the other stdlib headers, rather than down here with the arrow headers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
cpp/src/arrow/util/span_test.cc
Outdated
| static_assert(std::is_same_v<decltype(span(vec)), span<int>>); | ||
| static_assert(std::is_same_v<decltype(span(const_arr)), span<const int>>); | ||
| static_assert(std::is_same_v<decltype(span(const_vec)), span<const int>>); | ||
| static_assert(std::is_same_v<decltype(span(arr)), std::span<int>>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| static_assert(std::is_same_v<decltype(span(arr)), std::span<int>>); | |
| static_assert(std::is_same_v<decltype(std::span(arr)), std::span<int>>); |
Should these have the namespace too?
cpp/src/arrow/util/span_test.cc
Outdated
| using testing::PrintToString; | ||
|
|
||
| namespace arrow::util { | ||
| namespace arrow_util_span_test { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still required for other members?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, i think this test file is no longer needed, so i will remove it.
Rationale for this change
Replace custom
arrow::util::spanimplementation with C++20std::spanas suggested in issue #48588. This modernizes the codebase and removes ~130 lines of custom code.What changes are included in this PR?
src/arrow/util/span.h(custom span implementation)arrow::util::span<T>usage withstd::span<T>(95 occurrences)#include "arrow/util/span.h"to#include <span>(41 files)Are these changes tested?
Yes - created comprehensive tests verifying std::span compatibility with all original arrow::util::span functionality including construction, subspan, element access, and byte conversion.
Are there any user-facing changes?
No user-facing changes.