19template<
typename ForwardIterator,
typename T>
20ForwardIterator binary_find(ForwardIterator first, ForwardIterator last,
const T &value)
22 const ForwardIterator it = std::lower_bound(first, last, value);
23 return (it == last || value < *it) ? last : it;
26template<
typename ForwardIterator,
typename T,
typename Compare>
27ForwardIterator binary_find(ForwardIterator first, ForwardIterator last,
const T &value, Compare comp)
29 const ForwardIterator it = std::lower_bound(first, last, value, comp);
30 return (it == last || comp(value, *it)) ? last : it;
33template<
typename Container,
typename UnaryOperation>
34Container transformInPlace(Container &&c, UnaryOperation op)
36 std::transform(std::begin(c), std::end(c), std::begin(c), op);
44template<
typename InputRange,
typename UnaryPredicate>
45bool all_of(
const InputRange &range, UnaryPredicate p)
47 return std::all_of(std::begin(range), std::end(range), p);
55template<
typename InputRange,
typename UnaryPredicate>
56bool any_of(
const InputRange &range, UnaryPredicate p)
58 return std::any_of(std::begin(range), std::end(range), p);
65template<
typename InputRange,
typename UnaryPredicate>
66auto count_if(
const InputRange &range, UnaryPredicate p)
68 return std::count_if(std::begin(range), std::end(range), p);
75template<
typename InputRange,
typename UnaryPredicate>
76auto find_if(
const InputRange &range, UnaryPredicate p)
78 return std::find_if(std::begin(range), std::end(range), p);
85template<
typename InputRange,
typename UnaryFunction>
86UnaryFunction for_each(
const InputRange &range, UnaryFunction f)
88 return std::for_each(std::begin(range), std::end(range), f);
96template<
typename Container,
typename Key>
97bool contains(
const Container &container,
const Key &key)
99 return std::find(std::begin(container), std::end(container), key) != std::end(container);
105template<
typename InputRange,
typename UnaryPredicate>
106bool contains_if(
const InputRange &range, UnaryPredicate p)
108 return Kleo::find_if(range, p) != std::end(range);
115template<
typename InputRange,
typename OutputIterator,
typename UnaryPredicate>
116OutputIterator
copy(InputRange &&range, OutputIterator result)
118 return std::copy(std::begin(range), std::end(range), result);
126template<
typename InputRange,
typename OutputIterator,
typename UnaryPredicate>
127OutputIterator copy_if(InputRange &&range, OutputIterator result, UnaryPredicate p)
129 return std::copy_if(std::begin(range), std::end(range), result, p);
136template<
typename InputRange,
typename OutputIterator,
typename UnaryOperation>
137OutputIterator
transform(InputRange &&range, OutputIterator result, UnaryOperation op)
139 return std::transform(std::begin(range), std::end(range), result, op);
147template<
typename Vector,
typename UnaryPredicate>
148void erase_if(Vector &v, UnaryPredicate p)
150 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)