[PATCH] D143976: [ADT] Add `at` method (assertive lookup) to DenseMap and StringMap

Xiangxi Guo (Ryan) via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 15 11:10:58 PST 2023


StrongerXi added a comment.

>> Could you also add this to StringMap?
>
> Maybe IntervalMap and MapVector too?

I was thinking about this, didn't want to go too aggressive. But it should be easy to add once we reach consensus on the API here:).



================
Comment at: llvm/include/llvm/ADT/DenseMap.h:206
+  /// entry exists.
+  ValueT at(const_arg_type_t<KeyT> Val) const {
+    auto Iter = this->find(std::move(Val));
----------------
foad wrote:
> Just a question: would it be better to return `const ValueT &` like `std::map::at` would? Do we also want a non-const version of this?
Good question, I'm following the signature of existing `lookup` methods, I _guess_ the reason is more flexible API?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143976/new/

https://reviews.llvm.org/D143976



More information about the llvm-commits mailing list