libstdc++
chrono
Go to the documentation of this file.
00001 // <chrono> -*- C++ -*-
00002 
00003 // Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file include/chrono
00026  *  This is a Standard C++ Library header.
00027  */
00028 
00029 #ifndef _GLIBCXX_CHRONO
00030 #define _GLIBCXX_CHRONO 1
00031 
00032 #pragma GCC system_header
00033 
00034 #ifndef __GXX_EXPERIMENTAL_CXX0X__
00035 # include <bits/c++0x_warning.h>
00036 #else
00037 
00038 #include <ratio>
00039 #include <type_traits>
00040 #include <limits>
00041 #include <ctime>
00042 
00043 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
00044 
00045 namespace std _GLIBCXX_VISIBILITY(default)
00046 {
00047   /**
00048    * @defgroup chrono Time
00049    * @ingroup utilities
00050    *
00051    * Classes and functions for time.
00052    * @{
00053    */
00054 
00055   /** @namespace std::chrono
00056    *  @brief ISO C++ 0x entities sub namespace for time and date.
00057    */
00058   namespace chrono
00059   {
00060   _GLIBCXX_BEGIN_NAMESPACE_VERSION
00061 
00062     template<typename _Rep, typename _Period = ratio<1>>
00063       struct duration;
00064 
00065     template<typename _Clock, typename _Dur = typename _Clock::duration>
00066       struct time_point;
00067 
00068   _GLIBCXX_END_NAMESPACE_VERSION
00069   }
00070 
00071 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00072   // 20.8.2.3 specialization of common_type (for duration)
00073   template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
00074     struct common_type<chrono::duration<_Rep1, _Period1>,
00075                chrono::duration<_Rep2, _Period2>>
00076     {
00077     private:
00078       typedef __static_gcd<_Period1::num, _Period2::num>    __gcd_num;
00079       typedef __static_gcd<_Period1::den, _Period2::den>    __gcd_den;
00080       typedef typename common_type<_Rep1, _Rep2>::type      __cr;
00081       typedef ratio<__gcd_num::value,
00082             (_Period1::den / __gcd_den::value) * _Period2::den> __r;
00083 
00084     public:
00085       typedef chrono::duration<__cr, __r>           type;
00086     };
00087 
00088   // 20.8.2.3 specialization of common_type (for time_point)
00089   template<typename _Clock, typename _Dur1, typename _Dur2>
00090     struct common_type<chrono::time_point<_Clock, _Dur1>,
00091                chrono::time_point<_Clock, _Dur2>>
00092     {
00093     private:
00094       typedef typename common_type<_Dur1, _Dur2>::type      __ct;
00095 
00096     public:
00097       typedef chrono::time_point<_Clock, __ct>          type;
00098     };
00099 _GLIBCXX_END_NAMESPACE_VERSION
00100 
00101   namespace chrono
00102   {
00103   _GLIBCXX_BEGIN_NAMESPACE_VERSION
00104 
00105     // Primary template for duration_cast impl.
00106     template<typename _ToDur, typename _CF, typename _CR,
00107          bool _NumIsOne = false, bool _DenIsOne = false>
00108       struct __duration_cast_impl
00109       {
00110     template<typename _Rep, typename _Period>
00111       static constexpr _ToDur
00112       __cast(const duration<_Rep, _Period>& __d)
00113       {
00114         typedef typename _ToDur::rep            __to_rep;
00115         return _ToDur(static_cast<__to_rep>(static_cast<_CR>(__d.count())
00116           * static_cast<_CR>(_CF::num)
00117           / static_cast<_CR>(_CF::den)));
00118       }
00119       };
00120 
00121     template<typename _ToDur, typename _CF, typename _CR>
00122       struct __duration_cast_impl<_ToDur, _CF, _CR, true, true>
00123       {
00124     template<typename _Rep, typename _Period>
00125       static constexpr _ToDur
00126       __cast(const duration<_Rep, _Period>& __d)
00127       {
00128         typedef typename _ToDur::rep            __to_rep;
00129         return _ToDur(static_cast<__to_rep>(__d.count()));
00130       }
00131       };
00132 
00133     template<typename _ToDur, typename _CF, typename _CR>
00134       struct __duration_cast_impl<_ToDur, _CF, _CR, true, false>
00135       {
00136     template<typename _Rep, typename _Period>
00137       static constexpr _ToDur
00138       __cast(const duration<_Rep, _Period>& __d)
00139       {
00140         typedef typename _ToDur::rep            __to_rep;
00141         return _ToDur(static_cast<__to_rep>(
00142           static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den)));
00143       }
00144       };
00145 
00146     template<typename _ToDur, typename _CF, typename _CR>
00147       struct __duration_cast_impl<_ToDur, _CF, _CR, false, true>
00148       {
00149     template<typename _Rep, typename _Period>
00150       static constexpr _ToDur
00151       __cast(const duration<_Rep, _Period>& __d)
00152       {
00153         typedef typename _ToDur::rep            __to_rep;
00154         return _ToDur(static_cast<__to_rep>(
00155           static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num)));
00156       }
00157       };
00158 
00159     template<typename _Tp>
00160       struct __is_duration
00161       : std::false_type
00162       { };
00163 
00164     template<typename _Rep, typename _Period>
00165       struct __is_duration<duration<_Rep, _Period>>
00166       : std::true_type
00167       { };
00168 
00169     /// duration_cast
00170     template<typename _ToDur, typename _Rep, typename _Period>
00171       constexpr typename enable_if<__is_duration<_ToDur>::value,
00172                    _ToDur>::type
00173       duration_cast(const duration<_Rep, _Period>& __d)
00174       {
00175     typedef typename _ToDur::period             __to_period;
00176     typedef typename _ToDur::rep                __to_rep;
00177     typedef ratio_divide<_Period, __to_period>      __r_div;
00178     typedef typename __r_div::type              __cf;
00179     typedef typename common_type<__to_rep, _Rep, intmax_t>::type
00180                                 __cr;
00181     typedef  __duration_cast_impl<_ToDur, __cf, __cr,
00182                       __cf::num == 1, __cf::den == 1> __dc;
00183     return __dc::__cast(__d);
00184       }
00185 
00186     /// treat_as_floating_point
00187     template<typename _Rep>
00188       struct treat_as_floating_point
00189       : is_floating_point<_Rep>
00190       { };
00191 
00192     /// duration_values
00193     template<typename _Rep>
00194       struct duration_values
00195       {
00196     static constexpr _Rep
00197     zero()
00198     { return _Rep(0); }
00199 
00200     static constexpr _Rep
00201     max()
00202     { return numeric_limits<_Rep>::max(); }
00203 
00204     static constexpr _Rep
00205     min()
00206     { return numeric_limits<_Rep>::lowest(); }
00207       };
00208 
00209     template<typename T>
00210       struct __is_ratio
00211       : std::false_type
00212       { };
00213 
00214     template<intmax_t _Num, intmax_t _Den>
00215       struct __is_ratio<ratio<_Num, _Den>>
00216       : std::true_type
00217       { };
00218 
00219     /// duration
00220     template<typename _Rep, typename _Period>
00221       struct duration
00222       {
00223     typedef _Rep                        rep;
00224     typedef _Period                     period;
00225 
00226     static_assert(!__is_duration<_Rep>::value, "rep cannot be a duration");
00227     static_assert(__is_ratio<_Period>::value,
00228               "period must be a specialization of ratio");
00229     static_assert(_Period::num > 0, "period must be positive");
00230 
00231     // 20.8.3.1 construction / copy / destroy
00232     constexpr duration() : __r() { }
00233 
00234     constexpr duration(const duration&) = default;
00235 
00236     template<typename _Rep2, typename = typename
00237            enable_if<is_convertible<_Rep2, rep>::value
00238              && (treat_as_floating_point<rep>::value
00239                  || !treat_as_floating_point<_Rep2>::value)>::type>
00240       constexpr explicit duration(const _Rep2& __rep)
00241       : __r(static_cast<rep>(__rep)) { }
00242 
00243     template<typename _Rep2, typename _Period2, typename = typename
00244            enable_if<treat_as_floating_point<rep>::value
00245              || (ratio_divide<_Period2, period>::type::den == 1
00246                  && !treat_as_floating_point<_Rep2>::value)>::type>
00247       constexpr duration(const duration<_Rep2, _Period2>& __d)
00248       : __r(duration_cast<duration>(__d).count()) { }
00249 
00250     ~duration() = default;
00251     duration& operator=(const duration&) = default;
00252 
00253     // 20.8.3.2 observer
00254     constexpr rep
00255     count() const
00256     { return __r; }
00257 
00258     // 20.8.3.3 arithmetic
00259     constexpr duration
00260     operator+() const
00261     { return *this; }
00262 
00263     constexpr duration
00264     operator-() const
00265     { return duration(-__r); }
00266 
00267     duration&
00268     operator++()
00269     {
00270       ++__r;
00271       return *this;
00272     }
00273 
00274     duration
00275     operator++(int)
00276     { return duration(__r++); }
00277 
00278     duration&
00279     operator--()
00280     {
00281       --__r;
00282       return *this;
00283     }
00284 
00285     duration
00286     operator--(int)
00287     { return duration(__r--); }
00288 
00289     duration&
00290     operator+=(const duration& __d)
00291     {
00292       __r += __d.count();
00293       return *this;
00294     }
00295 
00296     duration&
00297     operator-=(const duration& __d)
00298     {
00299       __r -= __d.count();
00300       return *this;
00301     }
00302 
00303     duration&
00304     operator*=(const rep& __rhs)
00305     {
00306       __r *= __rhs;
00307       return *this;
00308     }
00309 
00310     duration&
00311     operator/=(const rep& __rhs)
00312     {
00313       __r /= __rhs;
00314       return *this;
00315     }
00316 
00317     // DR 934.
00318     template<typename _Rep2 = rep>
00319       typename enable_if<!treat_as_floating_point<_Rep2>::value,
00320                  duration&>::type
00321       operator%=(const rep& __rhs)
00322       {
00323         __r %= __rhs;
00324         return *this;
00325       }
00326 
00327     template<typename _Rep2 = rep>
00328       typename enable_if<!treat_as_floating_point<_Rep2>::value,
00329                  duration&>::type
00330       operator%=(const duration& __d)
00331       {
00332         __r %= __d.count();
00333         return *this;
00334       }
00335 
00336     // 20.8.3.4 special values
00337     static constexpr duration
00338     zero()
00339     { return duration(duration_values<rep>::zero()); }
00340 
00341     static constexpr duration
00342     min()
00343     { return duration(duration_values<rep>::min()); }
00344 
00345     static constexpr duration
00346     max()
00347     { return duration(duration_values<rep>::max()); }
00348 
00349       private:
00350     rep __r;
00351       };
00352 
00353     template<typename _Rep1, typename _Period1,
00354          typename _Rep2, typename _Period2>
00355       constexpr typename common_type<duration<_Rep1, _Period1>,
00356                      duration<_Rep2, _Period2>>::type
00357       operator+(const duration<_Rep1, _Period1>& __lhs,
00358         const duration<_Rep2, _Period2>& __rhs)
00359       {
00360     typedef duration<_Rep1, _Period1>           __dur1;
00361     typedef duration<_Rep2, _Period2>           __dur2;
00362     typedef typename common_type<__dur1,__dur2>::type   __cd;
00363     return __cd(__cd(__lhs).count() + __cd(__rhs).count());
00364       }
00365 
00366     template<typename _Rep1, typename _Period1,
00367          typename _Rep2, typename _Period2>
00368       constexpr typename common_type<duration<_Rep1, _Period1>,
00369                      duration<_Rep2, _Period2>>::type
00370       operator-(const duration<_Rep1, _Period1>& __lhs,
00371         const duration<_Rep2, _Period2>& __rhs)
00372       {
00373     typedef duration<_Rep1, _Period1>           __dur1;
00374     typedef duration<_Rep2, _Period2>           __dur2;
00375     typedef typename common_type<__dur1,__dur2>::type   __cd;
00376     return __cd(__cd(__lhs).count() - __cd(__rhs).count());
00377       }
00378 
00379     template<typename _Rep1, typename _Rep2, bool =
00380          is_convertible<_Rep2,
00381                 typename common_type<_Rep1, _Rep2>::type>::value>
00382       struct __common_rep_type { };
00383 
00384     template<typename _Rep1, typename _Rep2>
00385       struct __common_rep_type<_Rep1, _Rep2, true>
00386       { typedef typename common_type<_Rep1, _Rep2>::type type; };
00387 
00388     template<typename _Rep1, typename _Period, typename _Rep2>
00389       constexpr
00390       duration<typename __common_rep_type<_Rep1, _Rep2>::type, _Period>
00391       operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
00392       {
00393     typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
00394       __cd;
00395     return __cd(__cd(__d).count() * __s);
00396       }
00397 
00398     template<typename _Rep1, typename _Rep2, typename _Period>
00399       constexpr
00400       duration<typename __common_rep_type<_Rep2, _Rep1>::type, _Period>
00401       operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
00402       { return __d * __s; }
00403 
00404     template<typename _Rep1, typename _Period, typename _Rep2>
00405       constexpr duration<typename __common_rep_type<_Rep1, typename
00406     enable_if<!__is_duration<_Rep2>::value, _Rep2>::type>::type, _Period>
00407       operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
00408       {
00409     typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
00410       __cd;
00411     return __cd(__cd(__d).count() / __s);
00412       }
00413 
00414     template<typename _Rep1, typename _Period1,
00415          typename _Rep2, typename _Period2>
00416       constexpr typename common_type<_Rep1, _Rep2>::type
00417       operator/(const duration<_Rep1, _Period1>& __lhs,
00418         const duration<_Rep2, _Period2>& __rhs)
00419       {
00420     typedef duration<_Rep1, _Period1>           __dur1;
00421     typedef duration<_Rep2, _Period2>           __dur2;
00422     typedef typename common_type<__dur1,__dur2>::type   __cd;
00423     return __cd(__lhs).count() / __cd(__rhs).count();
00424       }
00425 
00426     // DR 934.
00427     template<typename _Rep1, typename _Period, typename _Rep2>
00428       constexpr duration<typename __common_rep_type<_Rep1, typename
00429     enable_if<!__is_duration<_Rep2>::value, _Rep2>::type>::type, _Period>
00430       operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
00431       {
00432     typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
00433       __cd;
00434     return __cd(__cd(__d).count() % __s);
00435       }
00436 
00437     template<typename _Rep1, typename _Period1,
00438          typename _Rep2, typename _Period2>
00439       constexpr typename common_type<duration<_Rep1, _Period1>,
00440                      duration<_Rep2, _Period2>>::type
00441       operator%(const duration<_Rep1, _Period1>& __lhs,
00442         const duration<_Rep2, _Period2>& __rhs)
00443       {
00444     typedef duration<_Rep1, _Period1>           __dur1;
00445     typedef duration<_Rep2, _Period2>           __dur2;
00446     typedef typename common_type<__dur1,__dur2>::type   __cd;
00447     return __cd(__cd(__lhs).count() % __cd(__rhs).count());
00448       }
00449 
00450     // comparisons
00451     template<typename _Rep1, typename _Period1,
00452          typename _Rep2, typename _Period2>
00453       constexpr bool
00454       operator==(const duration<_Rep1, _Period1>& __lhs,
00455          const duration<_Rep2, _Period2>& __rhs)
00456       {
00457     typedef duration<_Rep1, _Period1>           __dur1;
00458     typedef duration<_Rep2, _Period2>           __dur2;
00459     typedef typename common_type<__dur1,__dur2>::type   __ct;
00460     return __ct(__lhs).count() == __ct(__rhs).count();
00461       }
00462 
00463     template<typename _Rep1, typename _Period1,
00464          typename _Rep2, typename _Period2>
00465       constexpr bool
00466       operator<(const duration<_Rep1, _Period1>& __lhs,
00467         const duration<_Rep2, _Period2>& __rhs)
00468       {
00469     typedef duration<_Rep1, _Period1>           __dur1;
00470     typedef duration<_Rep2, _Period2>           __dur2;
00471     typedef typename common_type<__dur1,__dur2>::type   __ct;
00472     return __ct(__lhs).count() < __ct(__rhs).count();
00473       }
00474 
00475     template<typename _Rep1, typename _Period1,
00476          typename _Rep2, typename _Period2>
00477       constexpr bool
00478       operator!=(const duration<_Rep1, _Period1>& __lhs,
00479          const duration<_Rep2, _Period2>& __rhs)
00480       { return !(__lhs == __rhs); }
00481 
00482     template<typename _Rep1, typename _Period1,
00483          typename _Rep2, typename _Period2>
00484       constexpr bool
00485       operator<=(const duration<_Rep1, _Period1>& __lhs,
00486          const duration<_Rep2, _Period2>& __rhs)
00487       { return !(__rhs < __lhs); }
00488 
00489     template<typename _Rep1, typename _Period1,
00490          typename _Rep2, typename _Period2>
00491       constexpr bool
00492       operator>(const duration<_Rep1, _Period1>& __lhs,
00493         const duration<_Rep2, _Period2>& __rhs)
00494       { return __rhs < __lhs; }
00495 
00496     template<typename _Rep1, typename _Period1,
00497          typename _Rep2, typename _Period2>
00498       constexpr bool
00499       operator>=(const duration<_Rep1, _Period1>& __lhs,
00500          const duration<_Rep2, _Period2>& __rhs)
00501       { return !(__lhs < __rhs); }
00502 
00503     /// nanoseconds
00504     typedef duration<int64_t, nano>     nanoseconds;
00505 
00506     /// microseconds
00507     typedef duration<int64_t, micro>    microseconds;
00508 
00509     /// milliseconds
00510     typedef duration<int64_t, milli>    milliseconds;
00511 
00512     /// seconds
00513     typedef duration<int64_t>       seconds;
00514 
00515     /// minutes
00516     typedef duration<int, ratio< 60>>   minutes;
00517 
00518     /// hours
00519     typedef duration<int, ratio<3600>>  hours;
00520 
00521     /// time_point
00522     template<typename _Clock, typename _Dur>
00523       struct time_point
00524       {
00525     typedef _Clock                      clock;
00526     typedef _Dur                        duration;
00527     typedef typename duration::rep              rep;
00528     typedef typename duration::period           period;
00529 
00530     constexpr time_point() : __d(duration::zero())
00531     { }
00532 
00533     constexpr explicit time_point(const duration& __dur)
00534     : __d(__dur)
00535     { }
00536 
00537     // conversions
00538     template<typename _Dur2>
00539       constexpr time_point(const time_point<clock, _Dur2>& __t)
00540       : __d(__t.time_since_epoch())
00541       { }
00542 
00543     // observer
00544     constexpr duration
00545     time_since_epoch() const
00546     { return __d; }
00547 
00548     // arithmetic
00549     time_point&
00550     operator+=(const duration& __dur)
00551     {
00552       __d += __dur;
00553       return *this;
00554     }
00555 
00556     time_point&
00557     operator-=(const duration& __dur)
00558     {
00559       __d -= __dur;
00560       return *this;
00561     }
00562 
00563     // special values
00564     static constexpr time_point
00565     min()
00566     { return time_point(duration::min()); }
00567 
00568     static constexpr time_point
00569     max()
00570     { return time_point(duration::max()); }
00571 
00572       private:
00573     duration __d;
00574       };
00575 
00576     /// time_point_cast
00577     template<typename _ToDur, typename _Clock, typename _Dur>
00578       constexpr typename enable_if<__is_duration<_ToDur>::value,
00579                    time_point<_Clock, _ToDur>>::type
00580       time_point_cast(const time_point<_Clock, _Dur>& __t)
00581       {
00582     typedef time_point<_Clock, _ToDur>          __time_point;
00583     return __time_point(duration_cast<_ToDur>(__t.time_since_epoch()));
00584       }
00585 
00586     template<typename _Clock, typename _Dur1,
00587          typename _Rep2, typename _Period2>
00588       constexpr time_point<_Clock,
00589     typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
00590       operator+(const time_point<_Clock, _Dur1>& __lhs,
00591         const duration<_Rep2, _Period2>& __rhs)
00592       {
00593     typedef duration<_Rep2, _Period2>           __dur2;
00594     typedef typename common_type<_Dur1,__dur2>::type    __ct;
00595     typedef time_point<_Clock, __ct>            __time_point;
00596     return __time_point(__lhs.time_since_epoch() + __rhs);
00597       }
00598 
00599     template<typename _Rep1, typename _Period1,
00600          typename _Clock, typename _Dur2>
00601       constexpr time_point<_Clock,
00602     typename common_type<duration<_Rep1, _Period1>, _Dur2>::type>
00603       operator+(const duration<_Rep1, _Period1>& __lhs,
00604         const time_point<_Clock, _Dur2>& __rhs)
00605       { 
00606     typedef duration<_Rep1, _Period1>           __dur1;
00607     typedef typename common_type<__dur1,_Dur2>::type    __ct;
00608     typedef time_point<_Clock, __ct>            __time_point;
00609     return __time_point(__rhs.time_since_epoch() + __lhs); 
00610       }
00611 
00612     template<typename _Clock, typename _Dur1,
00613          typename _Rep2, typename _Period2>
00614       constexpr time_point<_Clock,
00615     typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
00616       operator-(const time_point<_Clock, _Dur1>& __lhs,
00617         const duration<_Rep2, _Period2>& __rhs)
00618       { 
00619     typedef duration<_Rep2, _Period2>           __dur2;
00620     typedef typename common_type<_Dur1,__dur2>::type    __ct;
00621     typedef time_point<_Clock, __ct>            __time_point;
00622     return __time_point(__lhs.time_since_epoch() -__rhs); 
00623       }
00624 
00625     template<typename _Clock, typename _Dur1, typename _Dur2>
00626       constexpr typename common_type<_Dur1, _Dur2>::type
00627       operator-(const time_point<_Clock, _Dur1>& __lhs,
00628         const time_point<_Clock, _Dur2>& __rhs)
00629       { return __lhs.time_since_epoch() - __rhs.time_since_epoch(); }
00630 
00631     template<typename _Clock, typename _Dur1, typename _Dur2>
00632       constexpr bool
00633       operator==(const time_point<_Clock, _Dur1>& __lhs,
00634          const time_point<_Clock, _Dur2>& __rhs)
00635       { return __lhs.time_since_epoch() == __rhs.time_since_epoch(); }
00636 
00637     template<typename _Clock, typename _Dur1, typename _Dur2>
00638       constexpr bool
00639       operator!=(const time_point<_Clock, _Dur1>& __lhs,
00640          const time_point<_Clock, _Dur2>& __rhs)
00641       { return !(__lhs == __rhs); }
00642 
00643     template<typename _Clock, typename _Dur1, typename _Dur2>
00644       constexpr bool
00645       operator<(const time_point<_Clock, _Dur1>& __lhs,
00646         const time_point<_Clock, _Dur2>& __rhs)
00647       { return  __lhs.time_since_epoch() < __rhs.time_since_epoch(); }
00648 
00649     template<typename _Clock, typename _Dur1, typename _Dur2>
00650       constexpr bool
00651       operator<=(const time_point<_Clock, _Dur1>& __lhs,
00652          const time_point<_Clock, _Dur2>& __rhs)
00653       { return !(__rhs < __lhs); }
00654 
00655     template<typename _Clock, typename _Dur1, typename _Dur2>
00656       constexpr bool
00657       operator>(const time_point<_Clock, _Dur1>& __lhs,
00658         const time_point<_Clock, _Dur2>& __rhs)
00659       { return __rhs < __lhs; }
00660 
00661     template<typename _Clock, typename _Dur1, typename _Dur2>
00662       constexpr bool
00663       operator>=(const time_point<_Clock, _Dur1>& __lhs,
00664          const time_point<_Clock, _Dur2>& __rhs)
00665       { return !(__lhs < __rhs); }
00666 
00667     /// system_clock
00668     struct system_clock
00669     {
00670 #ifdef _GLIBCXX_USE_CLOCK_REALTIME
00671       typedef chrono::nanoseconds                   duration;
00672 #elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
00673       typedef chrono::microseconds                  duration;
00674 #else
00675       typedef chrono::seconds                       duration;
00676 #endif
00677 
00678       typedef duration::rep                     rep;
00679       typedef duration::period                  period;
00680       typedef chrono::time_point<system_clock, duration>    time_point;
00681 
00682       static_assert(system_clock::duration::min()
00683             < system_clock::duration::zero(),
00684             "a clock's minimum duration cannot be less than its epoch");
00685 
00686       static constexpr bool is_steady = false;
00687 
00688       static time_point
00689       now() noexcept;
00690 
00691       // Map to C API
00692       static std::time_t
00693       to_time_t(const time_point& __t) noexcept
00694       {
00695     return std::time_t(duration_cast<chrono::seconds>
00696                (__t.time_since_epoch()).count());
00697       }
00698 
00699       static time_point
00700       from_time_t(std::time_t __t) noexcept
00701       {
00702     typedef chrono::time_point<system_clock, seconds>   __from;
00703     return time_point_cast<system_clock::duration>
00704            (__from(chrono::seconds(__t)));
00705       }
00706     };
00707 
00708 #ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
00709     /// steady_clock
00710     struct steady_clock
00711     {
00712       typedef chrono::nanoseconds               duration;
00713       typedef duration::rep                 rep;
00714       typedef duration::period                  period;
00715       typedef chrono::time_point<steady_clock, duration>    time_point;
00716 
00717       static constexpr bool is_steady = true;
00718 
00719       static time_point
00720       now() noexcept;
00721     };
00722 #else
00723     typedef system_clock steady_clock;
00724 #endif
00725 
00726     typedef system_clock high_resolution_clock;
00727 
00728   _GLIBCXX_END_NAMESPACE_VERSION
00729   } // namespace chrono
00730 
00731   // @} group chrono
00732 } // namespace
00733 
00734 #endif //_GLIBCXX_USE_C99_STDINT_TR1
00735 
00736 #endif //__GXX_EXPERIMENTAL_CXX0X__
00737 
00738 #endif //_GLIBCXX_CHRONO