westonpace commented on a change in pull request #9643: URL: https://github.com/apache/arrow/pull/9643#discussion_r595521216
########## File path: cpp/src/arrow/util/iterator.h ########## @@ -44,16 +44,35 @@ struct IterationTraits { /// \brief a reserved value which indicates the end of iteration. By /// default this is NULLPTR since most iterators yield pointer types. /// Specialize IterationTraits if different end semantics are required. + /// + /// Note: This should not be used to determine if a given value is a + /// terminal value. Use IsIterationEnd (which uses IsEnd) instead. This + /// is only for returning terminal values. static T End() { return T(NULLPTR); } + + /// \brief Checks to see if the value is a terminal value. + /// A method is used here since T is not neccesarily comparable in many + /// cases even though it has a distinct final value + static bool IsEnd(const T& val) { return val == End(); } }; +template <typename T> +bool IsIterationEnd(const T& val) { + return IterationTraits<T>::IsEnd(val); +} + template <typename T> struct IterationTraits<util::optional<T>> { /// \brief by default when iterating through a sequence of optional, /// nullopt indicates the end of iteration. /// Specialize IterationTraits if different end semantics are required. static util::optional<T> End() { return util::nullopt; } + /// \brief by default when iterating through a sequenc of optional, Review comment: Fixed. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org