iterator: use index_type for the indices pseudo-container
This commit is contained in:
parent
4094a96160
commit
eef3327415
15
iterator.hpp
15
iterator.hpp
@ -251,14 +251,17 @@ namespace util {
|
|||||||
template <typename ContainerT>
|
template <typename ContainerT>
|
||||||
class indices {
|
class indices {
|
||||||
public:
|
public:
|
||||||
|
using value_type = typename index_type<ContainerT>::type;
|
||||||
|
|
||||||
indices (const ContainerT &_container):
|
indices (const ContainerT &_container):
|
||||||
m_container (_container)
|
m_container (_container)
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
class iterator : public std::iterator<std::forward_iterator_tag, std::size_t, std::size_t> {
|
class iterator {
|
||||||
public:
|
public:
|
||||||
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
|
||||||
iterator (std::size_t _index):
|
iterator (value_type _index):
|
||||||
m_index (_index)
|
m_index (_index)
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
@ -281,18 +284,18 @@ namespace util {
|
|||||||
return *this;
|
return *this;
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::size_t&
|
const value_type&
|
||||||
operator* (void) const&
|
operator* (void) const&
|
||||||
{
|
{
|
||||||
return m_index;
|
return m_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::size_t m_index;
|
value_type m_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
iterator begin (void) const { return iterator { 0 }; }
|
iterator begin (void) const { return iterator { value_type {0} }; }
|
||||||
iterator end (void) const { return iterator { m_container.size () }; }
|
iterator end (void) const { return iterator { value_type (m_container.size ()) }; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ContainerT &m_container;
|
const ContainerT &m_container;
|
||||||
|
Loading…
Reference in New Issue
Block a user