[PATCH] D146893: [ADT] Work around MSVC bug affecting `get(enumerator_result)`
Jakub Kuderski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 27 07:36:29 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95abf86060ec: [ADT] Work around MSVC bug affecting `get(enumerator_result)` (authored by kuhar).
Changed prior to commit:
https://reviews.llvm.org/D146893?vs=508360&id=508653#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146893/new/
https://reviews.llvm.org/D146893
Files:
llvm/include/llvm/ADT/STLExtras.h
Index: llvm/include/llvm/ADT/STLExtras.h
===================================================================
--- llvm/include/llvm/ADT/STLExtras.h
+++ llvm/include/llvm/ADT/STLExtras.h
@@ -2311,14 +2311,21 @@
return Storage;
}
- /// Returns the value at index `I`. This includes the index.
- template <std::size_t I>
- friend decltype(auto) get(const enumerator_result &Result) {
- static_assert(I < NumValues, "Index out of bounds");
- if constexpr (I == 0)
- return Result.Idx;
- else
- return std::get<I - 1>(Result.Storage);
+ /// Returns the value at index `I`. This case covers the index.
+ template <std::size_t I, typename = std::enable_if_t<I == 0>>
+ friend std::size_t get(const enumerator_result &Result) {
+ return Result.Idx;
+ }
+
+ /// Returns the value at index `I`. This case covers references to the
+ /// iteratees.
+ template <std::size_t I, typename = std::enable_if_t<I != 0>>
+ friend std::tuple_element_t<I, value_reference_tuple>
+ get(const enumerator_result &Result) {
+ // Note: This is a separate function from the other `get`, instead of an
+ // `if constexpr` case, to work around an MSVC 19.31.31XXX compiler
+ // (Visual Studio 2022 17.1) return type deduction bug.
+ return std::get<I - 1>(Result.Storage);
}
template <typename... Ts>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146893.508653.patch
Type: text/x-patch
Size: 1336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230327/6d1e2804/attachment.bin>
More information about the llvm-commits
mailing list