Adding to file imp_iterator

This commit is contained in:
Vicente Mataix Ferrándiz 2018-10-23 13:10:59 +02:00
parent 5ac2d65047
commit b702163c9a
2 changed files with 48 additions and 1 deletions

View File

@ -209,6 +209,54 @@ class iter_impl
}
public:
/// return whether the iterator can be dereferenced
constexpr bool is_begin() const noexcept
{
assert(m_object != nullptr);
switch (m_object->m_type)
{
case value_t::object:
{
return m_it.object_iterator == m_object->m_value.object->begin();
}
case value_t::array:
{
return m_it.array_iterator == m_object->m_value.array->begin();
}
case value_t::null:
JSON_THROW(invalid_iterator::create(214, "cannot get value"));
default:
{
return m_it.primitive_iterator.is_begin();
}
}
}
/// return whether the iterator is at end
constexpr bool is_end() const noexcept
{
assert(m_object != nullptr);
switch (m_object->m_type)
{
case value_t::object:
{
return m_it.object_iterator == m_object->m_value.object->end();
}
case value_t::array:
{
return m_it.array_iterator == m_object->m_value.array->end();
}
case value_t::null:
JSON_THROW(invalid_iterator::create(214, "cannot get value"));
default:
{
return m_it.primitive_iterator.is_end();
}
}
}
/*!
@brief return a reference to the value pointed to by the iterator
@pre The iterator is initialized; i.e. `m_object != nullptr`.

View File

@ -5647,7 +5647,6 @@ class iter_impl
}
public:
/// return whether the iterator can be dereferenced
constexpr bool is_begin() const noexcept
{