forked from boostorg/range
implemented drop_front and drop_back with test.
This commit is contained in:
@ -206,12 +206,18 @@ public:
|
||||
return *m_Begin;
|
||||
}
|
||||
|
||||
void pop_front()
|
||||
void drop_front()
|
||||
{
|
||||
BOOST_ASSERT(!empty());
|
||||
++m_Begin;
|
||||
}
|
||||
|
||||
void drop_front(difference_type n)
|
||||
{
|
||||
BOOST_ASSERT(n >= difference_type());
|
||||
std::advance(this->m_Begin, n);
|
||||
}
|
||||
|
||||
protected:
|
||||
template<class Iterator>
|
||||
void assign(Iterator first, Iterator last)
|
||||
@ -256,17 +262,26 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
BOOST_DEDUCED_TYPENAME base_type::reference back() const
|
||||
typedef BOOST_DEDUCED_TYPENAME base_type::difference_type difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME base_type::reference reference;
|
||||
|
||||
reference back() const
|
||||
{
|
||||
BOOST_ASSERT(!this->empty());
|
||||
return *boost::prior(this->m_End);
|
||||
}
|
||||
|
||||
void pop_back()
|
||||
void drop_back()
|
||||
{
|
||||
BOOST_ASSERT(!this->empty());
|
||||
--this->m_End;
|
||||
}
|
||||
|
||||
void drop_back(difference_type n)
|
||||
{
|
||||
BOOST_ASSERT(n >= difference_type());
|
||||
std::advance(this->m_End, -n);
|
||||
}
|
||||
};
|
||||
|
||||
template<class IteratorT>
|
||||
@ -328,20 +343,6 @@ public:
|
||||
return this->m_Begin[at];
|
||||
}
|
||||
|
||||
void pop_front(difference_type n)
|
||||
{
|
||||
BOOST_ASSERT(n >= difference_type());
|
||||
BOOST_ASSERT(size() >= static_cast<size_type>(n));
|
||||
std::advance(this->m_Begin, n);
|
||||
}
|
||||
|
||||
void pop_back(difference_type n)
|
||||
{
|
||||
BOOST_ASSERT(n >= difference_type());
|
||||
BOOST_ASSERT(size() >= static_cast<size_type>(n));
|
||||
std::advance(this->m_End, -n);
|
||||
}
|
||||
|
||||
BOOST_DEDUCED_TYPENAME base_type::size_type size() const
|
||||
{
|
||||
return this->m_End - this->m_Begin;
|
||||
|
Reference in New Issue
Block a user