iterator: use index_type for the indices pseudo-container

This commit is contained in:
Danny Robson 2018-06-27 17:57:47 +10:00
parent 4094a96160
commit eef3327415

View File

@ -251,14 +251,17 @@ namespace util {
template <typename ContainerT>
class indices {
public:
using value_type = typename index_type<ContainerT>::type;
indices (const ContainerT &_container):
m_container (_container)
{ ; }
class iterator : public std::iterator<std::forward_iterator_tag, std::size_t, std::size_t> {
class iterator {
public:
using iterator_category = std::forward_iterator_tag;
iterator (std::size_t _index):
iterator (value_type _index):
m_index (_index)
{ ; }
@ -281,18 +284,18 @@ namespace util {
return *this;
};
const std::size_t&
const value_type&
operator* (void) const&
{
return m_index;
}
private:
std::size_t m_index;
value_type m_index;
};
iterator begin (void) const { return iterator { 0 }; }
iterator end (void) const { return iterator { m_container.size () }; }
iterator begin (void) const { return iterator { value_type {0} }; }
iterator end (void) const { return iterator { value_type (m_container.size ()) }; }
private:
const ContainerT &m_container;