Boost logo

Boost :

Subject: [boost] Why is iterator_traits<unordered_map<K, M>>::pointer a detail::ptr_node type rather than value_type *?
From: Alex Mohr (amohr_at_[hidden])
Date: 2014-10-17 17:06:10


The iterator type looks like:

template <typename NodePointer, typename Value>
struct iterator
     : public boost::iterator<
         std::forward_iterator_tag, Value, std::ptrdiff_t,
         NodePointer, Value&>

The NodePointer argument here (which is
boost::unordered::detail::ptr_node<...>) becomes the
iterator_traits<>::pointer type.

But iterator's operator->() returns Value *:

Value* operator->() const {
     return &node_->value();
}

Why shouldn't iterator_traits<>::pointer be Value* here? This
detail::ptr_node<> type seems intended to be completely internal.

Thanks,

Alex


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk