[llvm] [ADT] Fix llvm::concat_iterator for `ValueT == common_base_class *` (PR #144744)
Javier Lopez-Gomez via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 17 10:10:07 PDT 2025
================
@@ -996,13 +1003,17 @@ class concat_iterator
static constexpr bool ReturnsByValue =
!(std::is_reference_v<decltype(*std::declval<IterTs>())> && ...);
-
+ static constexpr bool ReturnsConvertibleType =
+ !all_types_equal_v<std::remove_cv_t<ValueT>,
+ std::remove_cv_t<std::remove_reference_t<
+ decltype(*std::declval<IterTs>())>>...> &&
+ (std::is_convertible_v<decltype(*std::declval<IterTs>()), ValueT> && ...);
+
+ // Cannot return a reference type if a conversion takes place, provided that
+ // the result of dereferencing all `IterTs...` is convertible to `ValueT`.
using reference_type =
- typename std::conditional_t<ReturnsByValue, ValueT, ValueT &>;
-
- using handle_type =
- typename std::conditional_t<ReturnsByValue, std::optional<ValueT>,
- ValueT *>;
+ typename std::conditional_t<ReturnsByValue || ReturnsConvertibleType,
----------------
jalopezg-git wrote:
It should not be needed; removed. PTAL and feel free to approve it it is all good :+1:.
https://github.com/llvm/llvm-project/pull/144744
More information about the llvm-commits
mailing list