| 1794 | |
| 1795 | template <typename... Args> |
| 1796 | std::pair<iterator, bool> emplace(Args&&... args) { |
| 1797 | ROBIN_HOOD_TRACE(this) |
| 1798 | Node n{*this, std::forward<Args>(args)...}; |
| 1799 | auto idxAndState = insertKeyPrepareEmptySpot(getFirstConst(n)); |
| 1800 | switch (idxAndState.second) { |
| 1801 | case InsertionState::key_found: |
| 1802 | n.destroy(*this); |
| 1803 | break; |
| 1804 | |
| 1805 | case InsertionState::new_node: |
| 1806 | ::new (static_cast<void*>(&mKeyVals[idxAndState.first])) Node(*this, std::move(n)); |
| 1807 | break; |
| 1808 | |
| 1809 | case InsertionState::overwrite_node: |
| 1810 | mKeyVals[idxAndState.first] = std::move(n); |
| 1811 | break; |
| 1812 | |
| 1813 | case InsertionState::overflow_error: |
| 1814 | n.destroy(*this); |
| 1815 | throwOverflowError(); |
| 1816 | break; |
| 1817 | } |
| 1818 | |
| 1819 | return std::make_pair(iterator(mKeyVals + idxAndState.first, mInfo + idxAndState.first), |
| 1820 | InsertionState::key_found != idxAndState.second); |
| 1821 | } |
| 1822 | |
| 1823 | template <typename... Args> |
| 1824 | iterator emplace_hint(const_iterator position, Args&&... args) { |