[llvm] [ADT] Fix llvm::concat_iterator for `ValueT == common_base_class *` (PR #144744)
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 20 08:50:58 PDT 2025
================
@@ -1032,13 +1032,17 @@ class concat_iterator
static constexpr bool ReturnsByValue =
!(std::is_reference_v<decltype(*std::declval<IterTs>())> && ...);
+ static constexpr bool ReturnsConvertiblePointer =
+ std::is_pointer_v<ValueT> &&
+ (std::is_convertible_v<decltype(*std::declval<IterTs>()), ValueT> && ...);
using reference_type =
- typename std::conditional_t<ReturnsByValue, ValueT, ValueT &>;
+ typename std::conditional_t<ReturnsByValue || ReturnsConvertiblePointer,
+ ValueT, ValueT &>;
- using handle_type =
- typename std::conditional_t<ReturnsByValue, std::optional<ValueT>,
- ValueT *>;
+ using handle_type = typename std::conditional_t<
+ ReturnsConvertiblePointer, ValueT,
+ std::conditional_t<ReturnsByValue, std::optional<ValueT>, ValueT *>>;
----------------
kuhar wrote:
This is getting complicated with the need for a nested condition -- could we move this to a new type trait struct or find some other way to simplify the code?
https://github.com/llvm/llvm-project/pull/144744
More information about the llvm-commits
mailing list