]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/icl/include/boost/icl/type_traits/succ_pred.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / icl / include / boost / icl / type_traits / succ_pred.hpp
1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2008-2011: Joachim Faulhaber
3 +------------------------------------------------------------------------------+
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENCE.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7 +-----------------------------------------------------------------------------*/
8 #ifndef BOOST_ICL_TYPE_TRAITS_SUCC_PRED_HPP_JOFA_080913
9 #define BOOST_ICL_TYPE_TRAITS_SUCC_PRED_HPP_JOFA_080913
10
11 #include <boost/icl/type_traits/is_increasing.hpp>
12
13 namespace boost{ namespace icl
14 {
15 template <class IncrementableT>
16 inline static IncrementableT succ(IncrementableT x) { return ++x; }
17
18 template <class DecrementableT>
19 inline static DecrementableT pred(DecrementableT x) { return --x; }
20
21 namespace detail
22 {
23 template <class DomainT, bool increasing = true>
24 struct successor;
25
26 template <class DomainT>
27 struct successor<DomainT, true>
28 {
29 typedef successor type;
30 inline static DomainT apply(DomainT value){ return ++value; }
31 };
32
33 template <class DomainT>
34 struct successor<DomainT, false>
35 {
36 typedef successor type;
37 inline static DomainT apply(DomainT value){ return --value; }
38 };
39
40 template <class DomainT, bool increasing = true>
41 struct predecessor;
42
43 template <class DomainT>
44 struct predecessor<DomainT, true>
45 {
46 typedef predecessor type;
47 inline static DomainT apply(DomainT value){ return --value; }
48 };
49
50 template <class DomainT>
51 struct predecessor<DomainT, false>
52 {
53 typedef predecessor type;
54 inline static DomainT apply(DomainT value){ return ++value; }
55 };
56 } // namespace detail
57
58 //------------------------------------------------------------------------------
59 template <class DomainT, class Compare>
60 struct successor
61 {
62 inline static DomainT apply(DomainT value)
63 {
64 return detail::successor
65 <DomainT, is_increasing<DomainT,Compare>::value>::apply(value);
66 }
67 };
68
69 template <class DomainT, class Compare>
70 struct predecessor
71 {
72 inline static DomainT apply(DomainT value)
73 {
74 return detail::predecessor
75 <DomainT, is_increasing<DomainT,Compare>::value>::apply(value);
76 }
77 };
78
79 }} // namespace boost icl
80
81 #endif
82
83