You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/09/26 19:59:08 UTC
[GitHub] [arrow] bkietz commented on a diff in pull request #14241: ARROW-17846: [C++] Use `if constexpr` in CSV subsystem
bkietz commented on code in PR #14241:
URL: https://github.com/apache/arrow/pull/14241#discussion_r980445728
##########
cpp/src/arrow/visit_type_inline.h:
##########
@@ -57,6 +57,33 @@ inline Status VisitTypeInline(const DataType& type, VISITOR* visitor) {
#undef TYPE_VISIT_INLINE
+#define TYPE_VISIT_INLINE(TYPE_CLASS) \
+ case TYPE_CLASS##Type::type_id: \
+ return std::forward<VISITOR>(visitor)( \
+ internal::checked_cast<const TYPE_CLASS##Type&>(type));
+
+/// \brief Call `visitor` with the corresponding concrete type class
+///
+/// Unlike VisitTypeInline which calls `visitor.Visit`, here `visitor`
+/// itself is called.
+/// `visitor` must support a `const DataType&` argument as a fallback,
+/// in addition to concrete type classes.
+///
+/// The intent is for this to be called on a generic lambda
+/// that may internally use `if constexpr` or similar constructs.
+template <typename VISITOR>
+inline auto VisitType(const DataType& type, VISITOR&& visitor)
Review Comment:
LGTM
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org