1 // Boost next_prior.hpp header file ---------------------------------------//
3 // (C) Copyright Boost.org 1999-2003. Permission to copy, use, modify, sell
4 // and distribute this software is granted provided this copyright
5 // notice appears in all copies. This software is provided "as is" without
6 // express or implied warranty, and with no claim as to its suitability for
9 // See http://www.boost.org/libs/utility for documentation.
12 // 13 Dec 2003 Added next(x, n) and prior(x, n) (Daniel Walker)
14 #ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED
15 #define BOOST_NEXT_PRIOR_HPP_INCLUDED
21 // Helper functions for classes like bidirectional iterators not supporting
22 // operator+ and operator-
25 // const std::list<T>::iterator p = get_some_iterator();
26 // const std::list<T>::iterator prev = boost::prior(p);
27 // const std::list<T>::iterator next = boost::next(prev, 2);
29 // Contributed by Dave Abrahams
32 inline T next(T x) { return ++x; }
34 template <class T, class Distance>
35 inline T next(T x, Distance n)
42 inline T prior(T x) { return --x; }
44 template <class T, class Distance>
45 inline T prior(T x, Distance n)
53 #endif // BOOST_NEXT_PRIOR_HPP_INCLUDED