Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

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(...).

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(...).
@llvmbot
Copy link
Member

llvmbot commented Sep 20, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

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 --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

@kazutakahirata kazutakahirata merged commit b5c6588 into llvm:main Sep 21, 2025
13 of 14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250920_10TMP_ADT_fallible_iterator_enable_if_struct_deref_supported branch September 21, 2025 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants