Date: Mon, 28 Aug 2023 22:00:46 +0300
Currently, there's `std::find` to iterate over the containers to check the
given element is in there or not. C++23 `std::basic_string` and
`std::basic_string_view` comes with handy function, called `contains()` to
check the substring is in there. Why would not the same functionality comes
with `std::vector`, `std::array` or other iterable containers?
Before, we would use that:
`if(std::find(vec.begin(), vec.end(), item) != vec.end()) {}`
With the power of `contains()`, we can use that:
`if(vec.contains(item)) {}`
given element is in there or not. C++23 `std::basic_string` and
`std::basic_string_view` comes with handy function, called `contains()` to
check the substring is in there. Why would not the same functionality comes
with `std::vector`, `std::array` or other iterable containers?
Before, we would use that:
`if(std::find(vec.begin(), vec.end(), item) != vec.end()) {}`
With the power of `contains()`, we can use that:
`if(vec.contains(item)) {}`
Received on 2023-08-28 19:00:59