manuzhang commented on code in PR #1066:
URL: https://github.com/apache/iceberg-cpp/pull/1066#discussion_r4388107637
##########
src/iceberg/util/stream.h:
##########
@@ -136,4 +141,26 @@ class Stream {
std::optional<Error> error_;
};
+template <typename T>
+std::unique_ptr<Stream<T>> Stream<T>::FromVector(std::vector<T> values) {
+ class VectorStream final : public Stream<T> {
+ public:
+ explicit VectorStream(std::vector<T> values) : values_(std::move(values))
{}
+
+ protected:
+ Result<std::optional<T>> NextImpl() override {
+ if (index_ == values_.size()) {
+ return std::nullopt;
+ }
+ return Result<std::optional<T>>(std::in_place, std::in_place,
+
std::move_if_noexcept(values_[index_++]));
Review Comment:
this doesn't work with `std::vector<bool>` which returns a temporary proxy
object for `values_[index_++]`
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]