20template<
typename ForwardIterator,
typename T>
21ForwardIterator binary_find(ForwardIterator first, ForwardIterator last,
const T &value)
23 const ForwardIterator it = std::lower_bound(first, last, value);
24 return (it == last || value < *it) ? last : it;
27template<
typename ForwardIterator,
typename T,
typename Compare>
28ForwardIterator binary_find(ForwardIterator first, ForwardIterator last,
const T &value, Compare comp)
30 const ForwardIterator it = std::lower_bound(first, last, value, comp);
31 return (it == last || comp(value, *it)) ? last : it;
34template<
typename Container,
typename UnaryOperation>
35Container transformInPlace(Container &&c, UnaryOperation op)
37 std::transform(std::begin(c), std::end(c), std::begin(c), op);
45template<
typename InputRange,
typename UnaryPredicate>
46bool all_of(
const InputRange &range, UnaryPredicate p)
48 return std::all_of(std::begin(range), std::end(range), p);
56template<
typename InputRange,
typename UnaryPredicate>
57bool any_of(
const InputRange &range, UnaryPredicate p)
59 return std::any_of(std::begin(range), std::end(range), p);
66template<
typename InputRange,
typename UnaryPredicate>
67auto count_if(
const InputRange &range, UnaryPredicate p)
69 return std::count_if(std::begin(range), std::end(range), p);
76template<
typename InputRange,
typename UnaryPredicate>
77auto find_if(
const InputRange &range, UnaryPredicate p)
79 return std::find_if(std::begin(range), std::end(range), p);
86template<
typename InputRange,
typename UnaryFunction>
87UnaryFunction for_each(
const InputRange &range, UnaryFunction f)
89 return std::for_each(std::begin(range), std::end(range), f);
97template<
typename Container,
typename Key>
98bool contains(
const Container &container,
const Key &key)
100 return std::find(std::begin(container), std::end(container), key) != std::end(container);
106template<
typename InputRange,
typename UnaryPredicate>
107bool contains_if(
const InputRange &range, UnaryPredicate p)
109 return Kleo::find_if(range, p) != std::end(range);
116template<
typename InputRange,
typename OutputIterator,
typename UnaryPredicate>
117OutputIterator
copy(InputRange &&range, OutputIterator result)
119 return std::copy(std::begin(range), std::end(range), result);
127template<
typename InputRange,
typename OutputIterator,
typename UnaryPredicate>
128OutputIterator copy_if(InputRange &&range, OutputIterator result, UnaryPredicate p)
130 return std::copy_if(std::begin(range), std::end(range), result, p);
137template<
typename InputRange,
typename OutputIterator,
typename UnaryOperation>
138OutputIterator
transform(InputRange &&range, OutputIterator result, UnaryOperation op)
140 return std::transform(std::begin(range), std::end(range), result, op);
147template<
typename InputRange,
typename OutputIterator,
typename UnaryOperation,
typename UnaryPredicate>
148OutputIterator transform_if(InputRange &&range, OutputIterator result, UnaryOperation op, UnaryPredicate p)
150 auto first = std::begin(range);
151 auto last = std::end(range);
152 for (
auto first = std::begin(range), last = std::end(range); first != last; ++first, (void)++result) {
153 if (std::invoke(p, *first)) {
154 *result = std::invoke(op, *first);
157 return std::move(result);
165template<
typename Vector,
typename UnaryPredicate>
166void erase_if(Vector &v, UnaryPredicate p)
168 v.erase(std::remove_if(std::begin(v), std::end(v), p), std::end(v));
KIOCORE_EXPORT CopyJob * copy(const QList< QUrl > &src, const QUrl &dest, JobFlags flags=DefaultFlags)