Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
libkleo
Commits
807d2eac
Commit
807d2eac
authored
Aug 05, 2022
by
Ingo Klöcker
Browse files
Add helper to check if all elements in a range satify a predicate
GnuPG-bug-id: 6115
parent
576de59a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/utils/algorithm.h
View file @
807d2eac
...
...
@@ -37,6 +37,16 @@ Container transformInPlace(Container &&c, UnaryOperation op)
return
std
::
move
(
c
);
}
/** Convenience helper for checking if the predicate @p p returns @c true
* for all elements in the range @p range. Returns @c true if the range is empty.
* Use ranges::all_of() instead if you can use C++20.
*/
template
<
typename
InputRange
,
typename
UnaryPredicate
>
bool
all_of
(
const
InputRange
&
range
,
UnaryPredicate
p
)
{
return
std
::
all_of
(
std
::
begin
(
range
),
std
::
end
(
range
),
p
);
}
/** Convenience helper for checking if a @p range contains at least one element
* for which predicate @p p returns @c true. Returns @c false if @p range is
* empty.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment