iterator,string: add size queries

This commit is contained in:
Danny Robson 2018-07-18 15:19:35 +10:00
parent 6f45f9514d
commit db24df329f
2 changed files with 15 additions and 0 deletions

View File

@ -297,6 +297,11 @@ namespace util {
iterator begin (void) const { return iterator { value_type {0} }; }
iterator end (void) const { return iterator { value_type (m_container.size ()) }; }
constexpr auto size (void) const noexcept
{
return std::size (m_container);
}
private:
const ContainerT &m_container;
};

View File

@ -127,6 +127,16 @@ namespace util {
iterator cend (void) const { return { { m_range.cend (), m_range.cend () }, m_separator }; }
iterator end (void) const { return { { m_range.cend (), m_range.cend () }, m_separator }; }
std::size_t
size (void) const
{
return std::count (
m_range.begin (),
m_range.end (),
m_separator
) + 1u;
}
private:
const range_type m_range;
const value_type m_separator;