Skip to content

Commit

Permalink
GH-39333: [C++] Don't use "if constexpr" in lambda (#39334)
Browse files Browse the repository at this point in the history
### 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 <antoine@python.org>
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
kou authored Dec 21, 2023
1 parent 3c66491 commit 5df541d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cpp/src/arrow/array/array_nested.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 5df541d

Please sign in to comment.