mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd::util: Add complement to std::for_each with our ircd::until().
This commit is contained in:
parent
481eff3baa
commit
0c145d0fbd
1 changed files with 20 additions and 0 deletions
|
@ -1220,5 +1220,25 @@ operator!(const string_view &str)
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Iterator based until() matching std::for_each except the function
|
||||
// returns a bool to continue rather than void.
|
||||
//
|
||||
template<class it_a,
|
||||
class it_b,
|
||||
class boolean_function>
|
||||
bool
|
||||
until(it_a a,
|
||||
const it_b &b,
|
||||
boolean_function&& f)
|
||||
{
|
||||
for(; a != b; ++a)
|
||||
if(!f(*a))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace util
|
||||
} // namespace ircd
|
||||
|
|
Loading…
Reference in a new issue