Remember, m_back refers to the next unused item, so if we have anything in the buffer, it will be stored in the previous element.
// In declaration
reference back();
const_reference back() const;
template <typename T, typename A>
inline
typename circular_buffer<T,A>::reference circular_buffer<T,A>::back()
{
assert(m_front);
return *wrap(m_back-1);
}
template <typename T, typename A>
inline
typename circular_buffer<T,A>::const_reference circular_buffer<T,A>::back() const
{
assert(m_front);
return *wrap(m_back-1);
}
No comments:
Post a Comment