]> git.lyx.org Git - lyx.git/blob - boost/boost/next_prior.hpp
fix reading the author field.
[lyx.git] / boost / boost / next_prior.hpp
1 //  Boost next_prior.hpp header file  ---------------------------------------//
2
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
7 //  any purpose.
8
9 //  See http://www.boost.org/libs/utility for documentation.
10
11 //  Revision History
12 //  13 Dec 2003  Added next(x, n) and prior(x, n) (Daniel Walker)
13
14 #ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED
15 #define BOOST_NEXT_PRIOR_HPP_INCLUDED
16
17 #include <iterator>
18
19 namespace boost {
20
21 //  Helper functions for classes like bidirectional iterators not supporting
22 //  operator+ and operator-
23 //
24 //  Usage:
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);
28
29 //  Contributed by Dave Abrahams
30
31 template <class T>
32 inline T next(T x) { return ++x; }
33
34 template <class T, class Distance>
35 inline T next(T x, Distance n)
36 {
37     std::advance(x, n);
38     return x;
39 }
40
41 template <class T>
42 inline T prior(T x) { return --x; }
43
44 template <class T, class Distance>
45 inline T prior(T x, Distance n)
46 {
47     std::advance(x, -n);
48     return x;
49 }
50
51 } // namespace boost
52
53 #endif  // BOOST_NEXT_PRIOR_HPP_INCLUDED