helpers: restore old behavior when playing a song already in playlist

This commit is contained in:
Andrzej Rybczak
2015-06-13 16:10:26 +02:00
parent bca788153d
commit b3c0c0798e
2 changed files with 30 additions and 2 deletions

View File

@@ -61,6 +61,26 @@ struct pointer_extractor
ValueT *operator()(ValueT &v) const { return &v; }
};
/// Map over the first element in range satisfying the predicate.
template <typename InputIterator, typename PredicateT, typename MapT>
InputIterator find_map_first(InputIterator first, InputIterator last, PredicateT &&p, MapT &&f)
{
auto it = std::find(first, last, std::forward<PredicateT>(p));
if (it != last)
f(*it);
return it;
}
/// Map over all elements in range satisfying the predicate.
template <typename InputIterator, typename PredicateT, typename MapT>
void find_map_all(InputIterator first, InputIterator last, PredicateT &&p, MapT &&f)
{
InputIterator it = first;
do
it = find_map_first(it, last, p, f);
while (it != last);
}
// identity function object
struct id_
{