iterator/indices: prefer std::size_t over holding a reference
This commit is contained in:
parent
7923a9fee2
commit
7af1268db8
@ -16,7 +16,7 @@ namespace cruft::iterator {
|
|||||||
using value_type = std::size_t;
|
using value_type = std::size_t;
|
||||||
|
|
||||||
indices (const ContainerT &_container):
|
indices (const ContainerT &_container):
|
||||||
m_container (_container)
|
m_target (_container.size ())
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
class iterator {
|
class iterator {
|
||||||
@ -56,16 +56,16 @@ namespace cruft::iterator {
|
|||||||
value_type m_index;
|
value_type m_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
iterator begin (void) const { return iterator { value_type {0} }; }
|
iterator begin (void) const { return iterator { 0u }; }
|
||||||
iterator end (void) const { return iterator { m_container.size () }; }
|
iterator end (void) const { return iterator { m_target }; }
|
||||||
|
|
||||||
constexpr auto size (void) const noexcept
|
constexpr auto size (void) const noexcept
|
||||||
{
|
{
|
||||||
return std::size (m_container);
|
return m_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ContainerT &m_container;
|
std::size_t m_target;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user