]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/icl/include/boost/icl/ptime.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / icl / include / boost / icl / ptime.hpp
1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2008-2009: 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
9 /*------------------------------------------------------------------------------
10 itl_ptime provides adapter code for boost::posix_time::ptime.
11 It implements incrementation (++) decrementation (--) and a neutral element
12 w.r.t. addition (identity_element()).
13 ------------------------------------------------------------------------------*/
14
15 #ifndef BOOST_ICL_PTIME_HPP_JOFA_080416
16 #define BOOST_ICL_PTIME_HPP_JOFA_080416
17
18 #include <boost/icl/detail/boost_config.hpp>
19 #include <boost/detail/workaround.hpp>
20
21 #ifdef BOOST_MSVC
22 #pragma warning(push)
23 #pragma warning(disable:4100) // boost/date_time/time.hpp(80) : warning C4100: 'as_offset' : unreferenced formal parameter
24 #pragma warning(disable:4127) // conditional expression is constant
25 #pragma warning(disable:4244) // 'argument' : conversion from 'int' to 'unsigned short', possible loss of data
26 #pragma warning(disable:4702) // boost\lexical_cast.hpp(1159) : warning C4702: unreachable code
27 #pragma warning(disable:4996) // Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
28 #endif
29
30 #include <stdio.h>
31 #include <string>
32 #include <sstream>
33 #include <iostream>
34 #include <boost/date_time/posix_time/posix_time.hpp>
35
36 #ifdef BOOST_MSVC
37 #pragma warning(pop)
38 #endif
39
40 #include <boost/icl/type_traits/identity_element.hpp>
41 #include <boost/icl/type_traits/difference_type_of.hpp>
42 #include <boost/icl/type_traits/size_type_of.hpp>
43 #include <boost/icl/type_traits/is_discrete.hpp>
44
45 namespace boost{namespace icl
46 {
47 template<> struct is_discrete<boost::posix_time::ptime>
48 {
49 typedef is_discrete type;
50 BOOST_STATIC_CONSTANT(bool, value = true);
51 };
52
53 template<>
54 inline boost::posix_time::ptime identity_element<boost::posix_time::ptime>::value()
55 {
56 return boost::posix_time::ptime(boost::posix_time::min_date_time);
57 }
58
59 template<>
60 struct has_difference<boost::posix_time::ptime>
61 {
62 typedef has_difference type;
63 BOOST_STATIC_CONSTANT(bool, value = true);
64 };
65
66 template<>
67 struct difference_type_of<boost::posix_time::ptime>
68 {
69 typedef boost::posix_time::time_duration type;
70 };
71
72 template<>
73 struct size_type_of<boost::posix_time::ptime>
74 {
75 typedef boost::posix_time::time_duration type;
76 };
77
78 // ------------------------------------------------------------------------
79 inline boost::posix_time::ptime operator ++(boost::posix_time::ptime& x)
80 {
81 return x += boost::posix_time::ptime::time_duration_type::unit();
82 }
83
84 inline boost::posix_time::ptime operator --(boost::posix_time::ptime& x)
85 {
86 return x -= boost::posix_time::ptime::time_duration_type::unit();
87 }
88
89 // ------------------------------------------------------------------------
90 template<> struct is_discrete<boost::posix_time::time_duration>
91 {
92 typedef is_discrete type;
93 BOOST_STATIC_CONSTANT(bool, value = true);
94 };
95
96 template<>
97 struct has_difference<boost::posix_time::time_duration>
98 {
99 typedef has_difference type;
100 BOOST_STATIC_CONSTANT(bool, value = true);
101 };
102
103 template<>
104 struct size_type_of<boost::posix_time::time_duration>
105 {
106 typedef boost::posix_time::time_duration type;
107 };
108
109 inline boost::posix_time::time_duration operator ++(boost::posix_time::time_duration& x)
110 {
111 return x += boost::posix_time::ptime::time_duration_type::unit();
112 }
113
114 inline boost::posix_time::time_duration operator --(boost::posix_time::time_duration& x)
115 {
116 return x -= boost::posix_time::ptime::time_duration_type::unit();
117 }
118 }} // namespace icl boost
119
120 #endif
121
122