[C++] `is_binary_like_type<T>` template condition fails to compile because missing `T::is_utf8` member
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the bug, including details regarding any error messages, version, and platform.
Tried to use template condition in the following code snippet:
```cpp
std::vector GetChunks(const int16_t* def_levels, const int16_t* rep_levels,
int64_t num_levels, const ::arrow::Array& values) {
auto handle_type = [&](auto&& type) -> std::vector {
using ArrowType = std::decay_t;
if constexpr (::arrow::is_binary_like_type::value) {
return CalculateBinaryLike<::arrow::BinaryArray>(def_levels, rep_levels,
num_levels, values);
} else {
throw ParquetException("Unsupported Arrow array type " +
values.type()->ToString());
}
};
return ::arrow::VisitType(*values.type(), handle_type);
}
```
but getting compiler error:
```
/Users/kszucs/Workspace/arrow/cpp/src/arrow/type_traits.h:719:70: error: no member named 'is_utf8' in 'arrow::Time64Type'
719 | std::integral_constant::value && T::is_utf8>;
| ~~~^
/Users/kszucs/Workspace/arrow/cpp/src/arrow/type_traits.h:744:36: note: in instantiation of template type alias 'is_string_like_type' requested here
744 | !is_string_like_type::value) ||
| ^
/Users/kszucs/Workspace/arrow/cpp/src/parquet/chunker_internal.cc:291:30: note: in instantiation of template type alias 'is_binary_like_type' requested here
291 | if constexpr (::arrow::is_binary_like_type::value) {
| ^
/Users/kszucs/Workspace/arrow/cpp/src/arrow/visit_type_inline.h:84:34: note: in instantiation of function template specialization 'parquet::internal::ContentDefinedChunker::Impl::GetChunks(const int16_t *, const int16_t *, int64_t, const ::arrow::Array &)::(anonymous class)::operator()' requested here
84 | ARROW_GENERATE_FOR_ALL_TYPES(TYPE_VISIT_INLINE);
| ^
/Users/kszucs/Workspace/arrow/cpp/src/parquet/chunker_internal.cc:299:21: note: in instantiation of function template specialization 'arrow::VisitType<(lambda at /Users/kszucs/Workspace/arrow/cpp/src/parquet/chunker_internal.cc:285:24) &>' requested here
299 | return ::arrow::VisitType(*values.type(), handle_type);
```
Seems like this condition cannot be used on its own without further specifying the type.
### Component(s)
C++
Contributor guide
Assessment
This issue has not been assessed yet.