diff --git a/SG14/slot_map.h b/SG14/slot_map.h index 2303aaf0..88193885 100644 --- a/SG14/slot_map.h +++ b/SG14/slot_map.h @@ -69,12 +69,12 @@ class slot_map #if __cplusplus >= 201703L static constexpr auto get_index(const Key& k) { const auto& [idx, gen] = k; return idx; } static constexpr auto get_generation(const Key& k) { const auto& [idx, gen] = k; return gen; } - template static constexpr void set_index(Key& k, Integral value) { auto& [idx, gen] = k; idx = static_cast(value); } + template static constexpr void set_index(Key& k, Integral value) { auto& [idx, gen] = k; idx = static_cast(value); } static constexpr void increment_generation(Key& k) { auto& [idx, gen] = k; ++gen; } #else static constexpr auto get_index(const Key& k) { using std::get; return get<0>(k); } static constexpr auto get_generation(const Key& k) { using std::get; return get<1>(k); } - template static constexpr void set_index(Key& k, Integral value) { using std::get; get<0>(k) = static_cast(value); } + template static constexpr void set_index(Key& k, Integral value) { using std::get; get<0>(k) = static_cast(value); } static constexpr void increment_generation(Key& k) { using std::get; ++get<1>(k); } #endif @@ -84,7 +84,7 @@ class slot_map using key_type = Key; using mapped_type = T; - using key_size_type = decltype(slot_map::get_index(std::declval())); + using key_index_type = decltype(slot_map::get_index(std::declval())); using key_generation_type = decltype(slot_map::get_generation(std::declval())); using container_type = Container; @@ -223,7 +223,7 @@ class slot_map slot_map_detail::reserve_if_possible(slots_, n); while (slots_.size() < n) { auto idx = next_available_slot_index_; - next_available_slot_index_ = static_cast(slots_.size()); + next_available_slot_index_ = static_cast(slots_.size()); slots_.emplace_back(key_type{idx, key_generation_type{}}); } } @@ -292,7 +292,7 @@ class slot_map slots_.clear(); values_.clear(); reverse_map_.clear(); - next_available_slot_index_ = key_size_type{}; + next_available_slot_index_ = key_index_type{}; } // swap is not mentioned in P0661r1 but it should be. @@ -328,21 +328,21 @@ class slot_map *value_iter = std::move(*value_back_iter); this->set_index(*slot_back_iter, value_index); auto reverse_map_iter = std::next(reverse_map_.begin(), value_index); - *reverse_map_iter = static_cast(std::distance(slots_.begin(), slot_back_iter)); + *reverse_map_iter = static_cast(std::distance(slots_.begin(), slot_back_iter)); } values_.pop_back(); reverse_map_.pop_back(); // Expire this key. this->set_index(*slot_iter, next_available_slot_index_); this->increment_generation(*slot_iter); - next_available_slot_index_ = static_cast(slot_index); + next_available_slot_index_ = static_cast(slot_index); return std::next(values_.begin(), value_index); } Container slots_; // high_water_mark() entries - Container reverse_map_; // exactly size() entries + Container reverse_map_; // exactly size() entries Container values_; // exactly size() entries - key_size_type next_available_slot_index_{}; + key_index_type next_available_slot_index_{}; }; template class Container> diff --git a/SG14_test/slot_map_test.cpp b/SG14_test/slot_map_test.cpp index 58bd839b..50e191b3 100644 --- a/SG14_test/slot_map_test.cpp +++ b/SG14_test/slot_map_test.cpp @@ -338,7 +338,7 @@ static void TypedefTests() using SM = stdext::slot_map; static_assert(std::is_same>::value, ""); static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); static_assert(std::is_same>::value, ""); static_assert(std::is_same::value, ""); @@ -356,7 +356,7 @@ static void TypedefTests() using SM = stdext::slot_map; static_assert(std::is_same>::value, ""); static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); static_assert(std::is_same>::value, ""); static_assert(std::is_same::reference>::value, ""); @@ -374,7 +374,7 @@ static void TypedefTests() using SM = stdext::slot_map; static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); static_assert(std::is_same>::value, ""); static_assert(std::is_same::value, ""); @@ -392,7 +392,7 @@ static void TypedefTests() using SM = stdext::slot_map, TestContainer::Vector>; static_assert(std::is_same>::value, ""); static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); static_assert(std::is_same>::value, ""); static_assert(std::is_same::value, ""); @@ -411,7 +411,7 @@ static void TypedefTests() using SM = stdext::slot_map; static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); static_assert(std::is_same>::value, ""); static_assert(std::is_same::value, "");