[llvm] [llvm][ADT] Structured bindings for move-only types in `StringMap` (PR #114676)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 2 17:58:47 PDT 2024


================
@@ -147,25 +147,33 @@ class StringMapEntry final : public StringMapEntryStorage<ValueTy> {
 };
 
 // Allow structured bindings on StringMapEntry.
+
+template <std::size_t Index, typename ValueTy>
+decltype(auto) get(StringMapEntry<ValueTy> &E) {
+  static_assert(Index == 0 || Index == 1);
+  if constexpr (Index == 0)
+    return E.getKey();
+  if constexpr (Index == 1)
----------------
kuhar wrote:

since this is guarded by the static assert above, we can use `else`

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


More information about the llvm-commits mailing list