Skip to content

Commit

Permalink
Rename the internal 'insert' with hint method to 'insert_hint' to avo…
Browse files Browse the repository at this point in the history
…id a potential ambiguous overload with the 'insert' with a pair of iterators.
  • Loading branch information
Tessil committed Feb 13, 2019
1 parent 161c292 commit 1855aad
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions include/tsl/robin_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ class robin_hash: private Hash, private KeyEqual, private GrowthPolicy {
}

template<typename P>
iterator insert(const_iterator hint, P&& value) {
iterator insert_hint(const_iterator hint, P&& value) {
if(hint != cend() && compare_keys(KeySelect()(*hint), KeySelect()(value))) {
return mutable_iterator(hint);
}
Expand Down Expand Up @@ -726,7 +726,7 @@ class robin_hash: private Hash, private KeyEqual, private GrowthPolicy {

template<class... Args>
iterator emplace_hint(const_iterator hint, Args&&... args) {
return insert(hint, value_type(std::forward<Args>(args)...));
return insert_hint(hint, value_type(std::forward<Args>(args)...));
}


Expand All @@ -739,7 +739,7 @@ class robin_hash: private Hash, private KeyEqual, private GrowthPolicy {
}

template<class K, class... Args>
iterator try_emplace(const_iterator hint, K&& key, Args&&... args) {
iterator try_emplace_hint(const_iterator hint, K&& key, Args&&... args) {
if(hint != cend() && compare_keys(KeySelect()(*hint), key)) {
return mutable_iterator(hint);
}
Expand Down
8 changes: 4 additions & 4 deletions include/tsl/robin_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class robin_map {


iterator insert(const_iterator hint, const value_type& value) {
return m_ht.insert(hint, value);
return m_ht.insert_hint(hint, value);
}

template<class P, typename std::enable_if<std::is_constructible<value_type, P&&>::value>::type* = nullptr>
Expand All @@ -269,7 +269,7 @@ class robin_map {
}

iterator insert(const_iterator hint, value_type&& value) {
return m_ht.insert(hint, std::move(value));
return m_ht.insert_hint(hint, std::move(value));
}


Expand Down Expand Up @@ -346,12 +346,12 @@ class robin_map {

template<class... Args>
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args) {
return m_ht.try_emplace(hint, k, std::forward<Args>(args)...);
return m_ht.try_emplace_hint(hint, k, std::forward<Args>(args)...);
}

template<class... Args>
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args) {
return m_ht.try_emplace(hint, std::move(k), std::forward<Args>(args)...);
return m_ht.try_emplace_hint(hint, std::move(k), std::forward<Args>(args)...);
}


Expand Down
4 changes: 2 additions & 2 deletions include/tsl/robin_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ class robin_set {
}

iterator insert(const_iterator hint, const value_type& value) {
return m_ht.insert(hint, value);
return m_ht.insert_hint(hint, value);
}

iterator insert(const_iterator hint, value_type&& value) {
return m_ht.insert(hint, std::move(value));
return m_ht.insert_hint(hint, std::move(value));
}

template<class InputIt>
Expand Down
7 changes: 7 additions & 0 deletions tests/robin_map_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,13 @@ BOOST_AUTO_TEST_CASE(test_extreme_bucket_count_value_construction) {
(std::numeric_limits<std::size_t>::max())), std::length_error);
}

BOOST_AUTO_TEST_CASE(test_range_construct) {
tsl::robin_map<int, int> map = {{2, 1}, {1, 0}, {3, 2}};

tsl::robin_map<int, int> map2(map.begin(), map.end());
tsl::robin_map<int, int> map3(map.cbegin(), map.cend());
}


/**
* operator=(std::initializer_list)
Expand Down

0 comments on commit 1855aad

Please sign in to comment.