C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Addition of std::contains to Simplify Container Value Checks

From: Jan Schultke <janschultke_at_[hidden]>
Date: Fri, 19 Jan 2024 22:45:12 +0100
I generally support the idea of *some* customization point, but there
needs to be a critical examination of all available options:
1. relying on the implementation to handle std::ranges::contains
specially for standard library containers
2. adding this new std::contains customization point
3. adding a contains() member function to all containers
4. simply burdening the user with making their own customization point

It's not obvious whether your chosen direction is best.

> bool containsOne = std::contains(numbers, {1, 4, 5}); // true

I *strongly* oppose this design. If you want this, you should make two
separate functions:
- std::contains_all
- std::contains_any


Sincerely
Jan

Received on 2024-01-19 21:45:24