iterator/indices: prefer std::size_t over holding a reference

This commit is contained in:
Danny Robson 2019-06-17 16:56:35 +10:00
parent 7923a9fee2
commit 7af1268db8

View File

@ -16,7 +16,7 @@ namespace cruft::iterator {
using value_type = std::size_t;
indices (const ContainerT &_container):
m_container (_container)
m_target (_container.size ())
{ ; }
class iterator {
@ -56,16 +56,16 @@ namespace cruft::iterator {
value_type m_index;
};
iterator begin (void) const { return iterator { value_type {0} }; }
iterator end (void) const { return iterator { m_container.size () }; }
iterator begin (void) const { return iterator { 0u }; }
iterator end (void) const { return iterator { m_target }; }
constexpr auto size (void) const noexcept
{
return std::size (m_container);
return m_target;
}
private:
const ContainerT &m_container;
std::size_t m_target;
};