[llvm] [Support] Simplify mapOptionalWithContext (NFC) (PR #137529)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 27 12:30:42 PDT 2025


================
@@ -901,11 +901,12 @@ class IO {
   }
 
   template <typename T, typename Context>
-  std::enable_if_t<has_SequenceTraits<T>::value, void>
-  mapOptionalWithContext(const char *Key, T &Val, Context &Ctx) {
-    // omit key/value instead of outputting empty sequence
-    if (this->canElideEmptySequence() && !(Val.begin() != Val.end()))
-      return;
+  void mapOptionalWithContext(const char *Key, T &Val, Context &Ctx) {
+    if constexpr (has_SequenceTraits<T>::value) {
+      // omit key/value instead of outputting empty sequence
+      if (this->canElideEmptySequence() && !(Val.begin() != Val.end()))
----------------
kazutakahirata wrote:

I wonder if `!=` is to accommodate bare minimum iterators that define `operator!=`, `operator*`, and `operator++`.  Anyway, builds and tests seem to pass with `==` here.

https://github.com/llvm/llvm-project/pull/137529


More information about the llvm-commits mailing list