next_prior.hpp
Go to the documentation of this file.
1 // Boost next_prior.hpp header file ---------------------------------------//
2 
3 // (C) Copyright Dave Abrahams and Daniel Walker 1999-2003. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 
7 // See http://www.boost.org/libs/utility for documentation.
8 
9 // Revision History
10 // 13 Dec 2003 Added next(x, n) and prior(x, n) (Daniel Walker)
11 
12 #ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED
13 #define BOOST_NEXT_PRIOR_HPP_INCLUDED
14 
15 #include <iterator>
16 #if defined(_MSC_VER) && _MSC_VER <= 1310
17 #include <boost/mpl/and.hpp>
19 #endif
27 
28 namespace boost {
29 
30 // Helper functions for classes like bidirectional iterators not supporting
31 // operator+ and operator-
32 //
33 // Usage:
34 // const std::list<T>::iterator p = get_some_iterator();
35 // const std::list<T>::iterator prev = boost::prior(p);
36 // const std::list<T>::iterator next = boost::next(prev, 2);
37 
38 // Contributed by Dave Abrahams
39 
40 namespace next_prior_detail {
41 
43 struct next_impl2
44 {
45  static T call(T x, Distance n)
46  {
47  std::advance(x, n);
48  return x;
49  }
50 };
51 
52 template< typename T, typename Distance >
53 struct next_impl2< T, Distance, true >
54 {
55  static T call(T x, Distance n)
56  {
57  return x + n;
58  }
59 };
60 
61 
63 struct next_impl1 :
64  public next_impl2< T, Distance >
65 {
66 };
67 
68 template< typename T, typename Distance >
69 struct next_impl1< T, Distance, true >
70 {
71  static T call(T x, Distance n)
72  {
73  x += n;
74  return x;
75  }
76 };
77 
78 
79 template<
80  typename T,
81  typename Distance,
82  typename PromotedDistance = typename integral_promotion< Distance >::type,
83 #if !defined(_MSC_VER) || _MSC_VER > 1310
85 #else
86  // MSVC 7.1 has problems with applying is_unsigned to non-integral types
88 #endif
89 >
91 {
92  static T call(T x, Distance n)
93  {
94  std::advance(x, -n);
95  return x;
96  }
97 };
98 
99 template< typename T, typename Distance, typename PromotedDistance >
100 struct prior_impl3< T, Distance, PromotedDistance, true >
101 {
102  static T call(T x, Distance n)
103  {
104  typedef typename make_signed< PromotedDistance >::type signed_distance;
105  std::advance(x, -static_cast< signed_distance >(static_cast< PromotedDistance >(n)));
106  return x;
107  }
108 };
109 
110 
112 struct prior_impl2 :
113  public prior_impl3< T, Distance >
114 {
115 };
116 
117 template< typename T, typename Distance >
118 struct prior_impl2< T, Distance, true >
119 {
120  static T call(T x, Distance n)
121  {
122  return x - n;
123  }
124 };
125 
126 
128 struct prior_impl1 :
129  public prior_impl2< T, Distance >
130 {
131 };
132 
133 template< typename T, typename Distance >
134 struct prior_impl1< T, Distance, true >
135 {
136  static T call(T x, Distance n)
137  {
138  x -= n;
139  return x;
140  }
141 };
142 
143 } // namespace next_prior_detail
144 
145 template <class T>
146 inline T next(T x) { return ++x; }
147 
148 template <class T, class Distance>
149 inline T next(T x, Distance n)
150 {
152 }
153 
154 template <class T>
155 inline T prior(T x) { return --x; }
156 
157 template <class T, class Distance>
158 inline T prior(T x, Distance n)
159 {
161 }
162 
163 } // namespace boost
164 
165 #endif // BOOST_NEXT_PRIOR_HPP_INCLUDED
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
GLfloat value
GLdouble n
Definition: glext.h:1966
GLdouble x
static T call(T x, Distance n)
Definition: next_prior.hpp:92
static T call(T x, Distance n)
Definition: next_prior.hpp:45
boost::type_traits::detail::integral_promotion< T, tag_type::value >::type type
T prior(T x)
Definition: next_prior.hpp:155
T next(T x)
Definition: next_prior.hpp:146
unsigned char advance


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:22