[llvm] [ADT] Simplify enable_if_struct_deref_supported (NFC) (PR #159939)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 20 11:20:10 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-adt
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
This patch simplifies enable_if_struct_deref_supported by using a
default template parameter as a temporary type alias. This way, we do
not have to repeat decltype(...).
---
Full diff: https://github.com/llvm/llvm-project/pull/159939.diff
1 Files Affected:
- (modified) llvm/include/llvm/ADT/fallible_iterator.h (+3-4)
``````````diff
diff --git a/llvm/include/llvm/ADT/fallible_iterator.h b/llvm/include/llvm/ADT/fallible_iterator.h
index b42f62b67fd66..76fa054f2eb94 100644
--- a/llvm/include/llvm/ADT/fallible_iterator.h
+++ b/llvm/include/llvm/ADT/fallible_iterator.h
@@ -67,10 +67,9 @@ namespace llvm {
/// without requiring redundant error checks.
template <typename Underlying> class fallible_iterator {
private:
- template <typename T>
- using enable_if_struct_deref_supported = std::enable_if_t<
- !std::is_void<decltype(std::declval<T>().operator->())>::value,
- decltype(std::declval<T>().operator->())>;
+ template <typename T, typename U = decltype(std::declval<T>().operator->())>
+ using enable_if_struct_deref_supported =
+ std::enable_if_t<!std::is_void_v<U>, U>;
public:
/// Construct a fallible iterator that *cannot* be used as an end-of-range
``````````
</details>
https://github.com/llvm/llvm-project/pull/159939
More information about the llvm-commits
mailing list