Little more refactoring.

This commit is contained in:
Vojtech Bubnik 2020-11-20 11:56:40 +01:00
parent ee932e4364
commit 060f1d48c1
2 changed files with 14 additions and 11 deletions

View file

@ -123,8 +123,10 @@ inline void append(std::vector<T>& dest, std::vector<T>&& src)
{
if (dest.empty())
dest = std::move(src);
else
else {
dest.resize(dest.size() + src.size());
std::move(std::begin(src), std::end(src), std::back_inserter(dest));
}
src.clear();
src.shrink_to_fit();
}
@ -164,7 +166,7 @@ inline std::unique_ptr<T> make_unique(Args&&... args) {
// Variant of std::lower_bound() with compare predicate, but without the key.
// This variant is very useful in case that the T type is large or it does not even have a public constructor.
template<class ForwardIt, class LowerThanKeyPredicate>
ForwardIt lower_bound_by_predicate(ForwardIt first, ForwardIt last, LowerThanKeyPredicate lower_thank_key)
ForwardIt lower_bound_by_predicate(ForwardIt first, ForwardIt last, LowerThanKeyPredicate lower_than_key)
{
ForwardIt it;
typename std::iterator_traits<ForwardIt>::difference_type count, step;
@ -174,7 +176,7 @@ ForwardIt lower_bound_by_predicate(ForwardIt first, ForwardIt last, LowerThanKey
it = first;
step = count / 2;
std::advance(it, step);
if (lower_thank_key(*it)) {
if (lower_than_key(*it)) {
first = ++it;
count -= step + 1;
}