...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::stl_interfaces::v1::reverse_iterator
// In header: <boost/stl_interfaces/reverse_iterator.hpp> template<typename BidiIter> struct reverse_iterator : public boost::stl_interfaces::v1::iterator_interface< reverse_iterator< BidiIter >, std::iterator_traits< BidiIter >::iterator_category, std::iterator_traits< BidiIter >::value_type, std::iterator_traits< BidiIter >::reference, std::iterator_traits< BidiIter >::pointer, std::iterator_traits< BidiIter >::difference_type > { // construct/copy/destruct reverse_iterator() noexcept(noexcept(BidiIter()))); reverse_iterator(BidiIter) noexcept(noexcept(BidiIter(it)))); template<typename BidiIter2, typename E = std::enable_if_t< std::is_convertible<BidiIter2, BidiIter>::value> > reverse_iterator(reverse_iterator< BidiIter2 > const &); // friend functions template<typename BidiIter2> friend struct reverse_iterator(); // public member functions constexpr std::iterator_traits< BidiIter >::reference operator *() const noexcept(noexcept(std::prev(v1_dtl::ce_prev(std::declval< BidiIter & >()))))); constexpr reverse_iterator & operator+=(typename std::iterator_traits< BidiIter >::difference_type) noexcept(noexcept(v1_dtl::ce_adv(std::declval< BidiIter & >(), -n, typename std::iterator_traits< BidiIter >::iterator_category{})))); constexpr BidiIter base() const noexcept; // private member functions constexpr BidiIter & base_reference() noexcept; constexpr BidiIter const & base_reference() const noexcept; };
This type is very similar to the C++20 version of std::reverse_iterator
; it is constexpr
-, noexcept
-, and proxy-friendly.
reverse_iterator
public
construct/copy/destructreverse_iterator() noexcept(noexcept(BidiIter())));
reverse_iterator(BidiIter it) noexcept(noexcept(BidiIter(it))));
template<typename BidiIter2, typename E = std::enable_if_t< std::is_convertible<BidiIter2, BidiIter>::value> > reverse_iterator(reverse_iterator< BidiIter2 > const & it);
reverse_iterator
public member functionsconstexpr std::iterator_traits< BidiIter >::reference operator *() const noexcept(noexcept(std::prev(v1_dtl::ce_prev(std::declval< BidiIter & >())))));
constexpr reverse_iterator & operator+=(typename std::iterator_traits< BidiIter >::difference_type n) noexcept(noexcept(v1_dtl::ce_adv(std::declval< BidiIter & >(), -n, typename std::iterator_traits< BidiIter >::iterator_category{}))));
constexpr BidiIter base() const noexcept;