Skip to content

Commit

Permalink
On range insert in tsl::array_map, try to move the value when possibl…
Browse files Browse the repository at this point in the history
…e (e.g. if the iterators are std::move_iterator).
  • Loading branch information
Tessil committed Jan 1, 2018
1 parent 5c7cb2a commit 5e91a05
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tsl/array_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class array_map {
}

for(auto it = first; it != last; ++it) {
insert(it->first, it->second);
insert_pair(*it);
}
}

Expand Down Expand Up @@ -778,6 +778,17 @@ class array_map {
lhs.swap(rhs);
}

private:
template<class U, class V>
void insert_pair(const std::pair<U, V>& value) {
insert(value.first, value.second);
}

template<class U, class V>
void insert_pair(std::pair<U, V>&& value) {
insert(value.first, std::move(value.second));
}

public:
static const size_type MAX_KEY_SIZE = ht::MAX_KEY_SIZE;

Expand Down

0 comments on commit 5e91a05

Please sign in to comment.