Mercurial > hg > vamp-build-and-test
annotate DEPENDENCIES/generic/include/boost/next_prior.hpp @ 16:2665513ce2d3
Add boost headers
| author | Chris Cannam |
|---|---|
| date | Tue, 05 Aug 2014 11:11:38 +0100 |
| parents | |
| children | c530137014c0 |
| rev | line source |
|---|---|
| Chris@16 | 1 // Boost next_prior.hpp header file ---------------------------------------// |
| Chris@16 | 2 |
| Chris@16 | 3 // (C) Copyright Dave Abrahams and Daniel Walker 1999-2003. Distributed under the Boost |
| Chris@16 | 4 // Software License, Version 1.0. (See accompanying file |
| Chris@16 | 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| Chris@16 | 6 |
| Chris@16 | 7 // See http://www.boost.org/libs/utility for documentation. |
| Chris@16 | 8 |
| Chris@16 | 9 // Revision History |
| Chris@16 | 10 // 13 Dec 2003 Added next(x, n) and prior(x, n) (Daniel Walker) |
| Chris@16 | 11 |
| Chris@16 | 12 #ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED |
| Chris@16 | 13 #define BOOST_NEXT_PRIOR_HPP_INCLUDED |
| Chris@16 | 14 |
| Chris@16 | 15 #include <iterator> |
| Chris@16 | 16 |
| Chris@16 | 17 namespace boost { |
| Chris@16 | 18 |
| Chris@16 | 19 // Helper functions for classes like bidirectional iterators not supporting |
| Chris@16 | 20 // operator+ and operator- |
| Chris@16 | 21 // |
| Chris@16 | 22 // Usage: |
| Chris@16 | 23 // const std::list<T>::iterator p = get_some_iterator(); |
| Chris@16 | 24 // const std::list<T>::iterator prev = boost::prior(p); |
| Chris@16 | 25 // const std::list<T>::iterator next = boost::next(prev, 2); |
| Chris@16 | 26 |
| Chris@16 | 27 // Contributed by Dave Abrahams |
| Chris@16 | 28 |
| Chris@16 | 29 template <class T> |
| Chris@16 | 30 inline T next(T x) { return ++x; } |
| Chris@16 | 31 |
| Chris@16 | 32 template <class T, class Distance> |
| Chris@16 | 33 inline T next(T x, Distance n) |
| Chris@16 | 34 { |
| Chris@16 | 35 std::advance(x, n); |
| Chris@16 | 36 return x; |
| Chris@16 | 37 } |
| Chris@16 | 38 |
| Chris@16 | 39 template <class T> |
| Chris@16 | 40 inline T prior(T x) { return --x; } |
| Chris@16 | 41 |
| Chris@16 | 42 template <class T, class Distance> |
| Chris@16 | 43 inline T prior(T x, Distance n) |
| Chris@16 | 44 { |
| Chris@16 | 45 std::advance(x, -n); |
| Chris@16 | 46 return x; |
| Chris@16 | 47 } |
| Chris@16 | 48 |
| Chris@16 | 49 } // namespace boost |
| Chris@16 | 50 |
| Chris@16 | 51 #endif // BOOST_NEXT_PRIOR_HPP_INCLUDED |
