You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ap...@apache.org on 2023/12/21 09:52:48 UTC

(arrow) branch main updated: GH-39333: [C++] Don't use "if constexpr" in lambda (#39334)

This is an automated email from the ASF dual-hosted git repository.

apitrou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5df541de94 GH-39333: [C++] Don't use "if constexpr" in lambda (#39334)
5df541de94 is described below

commit 5df541de94b4cf76a8b9a1cad6155ae781ea55dc
Author: Sutou Kouhei <ko...@clear-code.com>
AuthorDate: Thu Dec 21 18:52:36 2023 +0900

    GH-39333: [C++] Don't use "if constexpr" in lambda (#39334)
    
    ### Rationale for this change
    
    It seems that it's not portable. At least it doesn't work as expected with Visual Studio 2017:
    
        C:/arrow/cpp/src/arrow/array/array_nested.cc(291): error C2065: 'validity': undeclared identifier (compiling source file C:\arrow-build\src\arrow\CMakeFiles\arrow_shared.dir\Unity\unity_0_cxx.cxx) [C:\arrow-build\src\arrow\arrow_shared.vcxproj]
          C:/arrow/cpp/src/arrow/array/array_nested.cc(660): note: see reference to function template instantiation 'arrow::Result<std::shared_ptr<arrow::Array>> arrow::`anonymous-namespace'::FlattenListViewArray<arrow::ListViewArray,false>(const ListViewArrayT &,arrow::MemoryPool *)' being compiled
                  with
                  [
                      ListViewArrayT=arrow::ListViewArray
                  ] (compiling source file C:\arrow-build\src\arrow\CMakeFiles\arrow_shared.dir\Unity\unity_0_cxx.cxx)
          memory_pool.cc
        C:/arrow/cpp/src/arrow/array/array_nested.cc(291): error C2065: 'list_view_array_offset': undeclared identifier (compiling source file C:\arrow-build\src\arrow\CMakeFiles\arrow_shared.dir\Unity\unity_0_cxx.cxx) [C:\arrow-build\src\arrow\arrow_shared.vcxproj]
    ### What changes are included in this PR?
    
    Avoid "if constexpr" in lambda.
    
    ### Are these changes tested?
    
    Yes.
    
    ### Are there any user-facing changes?
    
    No.
    * Closes: #39333
    
    Lead-authored-by: Antoine Pitrou <an...@python.org>
    Co-authored-by: Sutou Kouhei <ko...@clear-code.com>
    Signed-off-by: Antoine Pitrou <an...@python.org>
---
 cpp/src/arrow/array/array_nested.cc | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/cpp/src/arrow/array/array_nested.cc b/cpp/src/arrow/array/array_nested.cc
index 03f3e5af29..acdd0a0742 100644
--- a/cpp/src/arrow/array/array_nested.cc
+++ b/cpp/src/arrow/array/array_nested.cc
@@ -287,10 +287,8 @@ Result<std::shared_ptr<Array>> FlattenListViewArray(const ListViewArrayT& list_v
   const auto* sizes = list_view_array.data()->template GetValues<offset_type>(2);
 
   auto is_null_or_empty = [&](int64_t i) {
-    if constexpr (HasNulls) {
-      if (!bit_util::GetBit(validity, list_view_array_offset + i)) {
-        return true;
-      }
+    if (HasNulls && !bit_util::GetBit(validity, list_view_array_offset + i)) {
+      return true;
     }
     return sizes[i] == 0;
   };