Add and use cxx20::ranges::all_of.

This commit is contained in:
Daniel Kirchner
2021-01-12 21:40:52 +01:00
parent 970e8064bb
commit 3ed55613ba
2 changed files with 15 additions and 4 deletions
+12
View File
@@ -49,4 +49,16 @@ erase_if(std::unordered_map<Key,T,Hash,KeyEqual,Alloc>& c, Pred pred)
return old_size - c.size();
}
namespace ranges
{
template<typename R, typename Pred>
inline constexpr bool all_of(R&& r, Pred pred)
{
for (auto it = std::begin(r), end = std::end(r); it != end; ++it)
if (!std::invoke(pred, *it))
return false;
return true;
}
}
}