我的课程hash_table
看起来像这样:
template <typename Key, typename Value, typename Alloc>
class hash_table {
public:
using key_type = Key;
using mapped_type = Value;
using allocator_type = Alloc;
using value_type = std::pair<const key_type, mapped_type>;
private:
template<typename Map, typename IterVal, typename Allocator>
class map_iterator;
using internal_value_t = std::pair<std::remove_const_t<key_type>, std::remove_const_t<mapped_type>>;
using internal_iterator = map_iterator<hash_table, internal_value_t, allocator_type>;
using const_internal_iterator = map_iterator<const hash_table, const_internal_value_t, allocator_type>;
public:
using iterator = ???;
using const_iterator = ???;
}
因为这是一个哈希表,我不希望该用户可以修改密钥,但是在地图内部,我想删除key_type和value_type的remove_const以启用move
数据
如何实施iterator
和const_iterator
(如std::unordered_map::iterator
引用map_iterator
指向的项目。
我很抱歉我的英语不好。