Codechange: Use std::ranges::find where possible.
Replace `std::find(range.begin(), range.end(), ...)` with `std::ranges::find(range, ...)`.
This commit is contained in:
committed by
Peter Nelson
parent
1f18894408
commit
3be0166801
@@ -23,7 +23,7 @@
|
||||
template <typename Container>
|
||||
inline bool include(Container &container, typename Container::const_reference &item)
|
||||
{
|
||||
const bool is_member = std::find(container.begin(), container.end(), item) != container.end();
|
||||
const bool is_member = std::ranges::find(container, item) != container.end();
|
||||
if (!is_member) container.emplace_back(item);
|
||||
return is_member;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ inline bool include(Container &container, typename Container::const_reference &i
|
||||
template <typename Container>
|
||||
int find_index(Container const &container, typename Container::const_reference item)
|
||||
{
|
||||
auto const it = std::find(container.begin(), container.end(), item);
|
||||
auto const it = std::ranges::find(container, item);
|
||||
if (it != container.end()) return std::distance(container.begin(), it);
|
||||
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user