| 1482 | template <class... ValueArgs, class U = T, |
| 1483 | typename std::enable_if<has_mapped_type<U>::value>::type* = nullptr> |
| 1484 | std::pair<iterator, bool> emplace_impl( |
| 1485 | std::size_t ibucket, typename array_bucket::const_iterator end_of_bucket, |
| 1486 | const CharT* key, size_type key_size, ValueArgs&&... value_args) { |
| 1487 | if (this->m_values.size() >= max_size()) { |
| 1488 | // Try to clear old erased values lingering in m_values. Throw if it |
| 1489 | // doesn't change anything. |
| 1490 | clear_old_erased_values(); |
| 1491 | if (this->m_values.size() >= max_size()) { |
| 1492 | throw std::length_error( |
| 1493 | "Can't insert value, too much values in the map."); |
| 1494 | } |
| 1495 | } |
| 1496 | |
| 1497 | if (this->m_values.size() == this->m_values.capacity()) { |
| 1498 | this->m_values.reserve( |
| 1499 | std::size_t(float(this->m_values.size()) * |
| 1500 | value_container<T>::VECTOR_GROWTH_RATE)); |
| 1501 | } |
| 1502 | |
| 1503 | this->m_values.emplace_back(std::forward<ValueArgs>(value_args)...); |
| 1504 | |
| 1505 | try { |
| 1506 | auto it = m_buckets[ibucket].append( |
| 1507 | end_of_bucket, key, key_size, IndexSizeT(this->m_values.size() - 1)); |
| 1508 | m_nb_elements++; |
| 1509 | |
| 1510 | return std::make_pair( |
| 1511 | iterator(m_buckets_data.begin() + ibucket, it, this), true); |
| 1512 | } catch (...) { |
| 1513 | // Rollback |
| 1514 | this->m_values.pop_back(); |
| 1515 | throw; |
| 1516 | } |
| 1517 | } |
| 1518 | |
| 1519 | template <class U = T, typename std::enable_if< |
| 1520 | !has_mapped_type<U>::value>::type* = nullptr> |