[PATCH] D146061: [ADT] Make llvm::is_contained call member `contains` when available

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 14 14:05:37 PDT 2023


kazu added a comment.

In D146061#4194466 <https://reviews.llvm.org/D146061#4194466>, @kuhar wrote:

> Then I propose we frame it like this: `llvm::is_contained` is the (llvm-only) canonical/generic way to check if an element is in the range.

How about something like the (llvm-only) canonical/generic way to check if an element is in the range if a template needs to work with containers that may or may not have the `.contains` method (like an array and a set).

I'm saying this because I personally find `Foo.contains(X)` a little more readable than `llvm::is_contained(Foo, X)`, and I would like our code base to look friendly to people new to the LLVM project (with the use of function names present in C++ standards) wherever reasonable to do so.  (Sure, `std::set::contains` is very new, but I expect people to become familiar with this over time.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146061



More information about the llvm-commits mailing list