Chris@16: /*-----------------------------------------------------------------------------+ Chris@16: Copyright (c) 2008-2009: Joachim Faulhaber Chris@16: +------------------------------------------------------------------------------+ Chris@16: Distributed under the Boost Software License, Version 1.0. Chris@16: (See accompanying file LICENCE.txt or copy at Chris@16: http://www.boost.org/LICENSE_1_0.txt) Chris@16: +-----------------------------------------------------------------------------*/ Chris@16: Chris@16: /*------------------------------------------------------------------------------ Chris@16: itl_ptime provides adapter code for boost::posix_time::ptime. Chris@16: It implements incrementation (++) decrementation (--) and a neutral element Chris@16: w.r.t. addition (identity_element()). Chris@16: ------------------------------------------------------------------------------*/ Chris@16: Chris@16: #ifndef BOOST_ICL_PTIME_HPP_JOFA_080416 Chris@16: #define BOOST_ICL_PTIME_HPP_JOFA_080416 Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(push) Chris@16: #pragma warning(disable:4100) // boost/date_time/time.hpp(80) : warning C4100: 'as_offset' : unreferenced formal parameter Chris@16: #pragma warning(disable:4127) // conditional expression is constant Chris@16: #pragma warning(disable:4244) // 'argument' : conversion from 'int' to 'unsigned short', possible loss of data Chris@16: #pragma warning(disable:4702) // boost\lexical_cast.hpp(1159) : warning C4702: unreachable code Chris@16: #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' Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost{namespace icl Chris@16: { Chris@16: template<> struct is_discrete Chris@16: { Chris@16: typedef is_discrete type; Chris@16: BOOST_STATIC_CONSTANT(bool, value = true); Chris@16: }; Chris@16: Chris@16: template<> Chris@16: inline boost::posix_time::ptime identity_element::value() Chris@16: { Chris@16: return boost::posix_time::ptime(boost::posix_time::min_date_time); Chris@16: } Chris@16: Chris@16: template<> Chris@16: struct has_difference Chris@16: { Chris@16: typedef has_difference type; Chris@16: BOOST_STATIC_CONSTANT(bool, value = true); Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct difference_type_of Chris@16: { Chris@16: typedef boost::posix_time::time_duration type; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct size_type_of Chris@16: { Chris@16: typedef boost::posix_time::time_duration type; Chris@16: }; Chris@16: Chris@16: // ------------------------------------------------------------------------ Chris@16: inline boost::posix_time::ptime operator ++(boost::posix_time::ptime& x) Chris@16: { Chris@16: return x += boost::posix_time::ptime::time_duration_type::unit(); Chris@16: } Chris@16: Chris@16: inline boost::posix_time::ptime operator --(boost::posix_time::ptime& x) Chris@16: { Chris@16: return x -= boost::posix_time::ptime::time_duration_type::unit(); Chris@16: } Chris@16: Chris@16: // ------------------------------------------------------------------------ Chris@16: template<> struct is_discrete Chris@16: { Chris@16: typedef is_discrete type; Chris@16: BOOST_STATIC_CONSTANT(bool, value = true); Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct has_difference Chris@16: { Chris@16: typedef has_difference type; Chris@16: BOOST_STATIC_CONSTANT(bool, value = true); Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct size_type_of Chris@16: { Chris@16: typedef boost::posix_time::time_duration type; Chris@16: }; Chris@16: Chris@16: inline boost::posix_time::time_duration operator ++(boost::posix_time::time_duration& x) Chris@16: { Chris@16: return x += boost::posix_time::ptime::time_duration_type::unit(); Chris@16: } Chris@16: Chris@16: inline boost::posix_time::time_duration operator --(boost::posix_time::time_duration& x) Chris@16: { Chris@16: return x -= boost::posix_time::ptime::time_duration_type::unit(); Chris@16: } Chris@16: }} // namespace icl boost Chris@16: Chris@16: #endif Chris@16: Chris@16: