[PATCH] D151557: [ADT] Fix DenseMapInfo<variant>::isEqual to delegate to DenseMapInfo, not ==
Sam McCall via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 04:27:57 PDT 2023
sammccall marked an inline comment as done.
sammccall added inline comments.
================
Comment at: llvm/include/llvm/ADT/DenseMapInfo.h:354-356
+ return std::visit(detail::EqVisitor{detail::variantGetDynamic(
+ RHS, std::make_index_sequence<sizeof...(Ts)>{})},
+ LHS);
----------------
IncludeGuardian wrote:
> I think we may be able to use `std::visit` twice and rely on the type of the parameter in the second visit matching the original type of the value we cast to `const void *`.
>
> ```
> const void *ErasedLHSValue = std::visit([](const auto& LHSValue){
> return static_cast<const void *>(&LHSValue);
> }, l);
>
> return std::visit([=](const auto& RHSValue){
> using T = std::remove_reference_t<decltype(RHSValue)>;
> return DenseMapInfo<T>::isEqual(*static_cast<T *>(ErasedLHSValue), RHSValue);
> }, r);
> ```
Right! I always forget that auto-params in lambdas are good for something other than saving typing :-)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151557/new/
https://reviews.llvm.org/D151557
More information about the llvm-commits
mailing list