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       inline 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>::min(); }
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       inline 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   __ct;
00363     return __ct(__lhs) += __rhs;
00364       }
00365 
00366     template<typename _Rep1, typename _Period1,
00367          typename _Rep2, typename _Period2>
00368       inline 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   __ct;
00376     return __ct(__lhs) -= __rhs;
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       inline duration<typename __common_rep_type<_Rep1, _Rep2>::type, _Period>
00390       operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
00391       {
00392     typedef typename common_type<_Rep1, _Rep2>::type    __cr;
00393     return duration<__cr, _Period>(__d) *= __s;
00394       }
00395 
00396     template<typename _Rep1, typename _Period, typename _Rep2>
00397       inline duration<typename __common_rep_type<_Rep2, _Rep1>::type, _Period>
00398       operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
00399       { return __d * __s; }
00400 
00401     template<typename _Rep1, typename _Period, typename _Rep2>
00402       inline duration<typename __common_rep_type<_Rep1, typename
00403     enable_if<!__is_duration<_Rep2>::value, _Rep2>::type>::type, _Period>
00404       operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
00405       {
00406     typedef typename common_type<_Rep1, _Rep2>::type    __cr;
00407     return duration<__cr, _Period>(__d) /= __s;
00408       }
00409 
00410      template<typename _Rep1, typename _Period1,
00411           typename _Rep2, typename _Period2>
00412       inline typename common_type<_Rep1, _Rep2>::type
00413       operator/(const duration<_Rep1, _Period1>& __lhs,
00414         const duration<_Rep2, _Period2>& __rhs)
00415       {
00416     typedef duration<_Rep1, _Period1>           __dur1;
00417     typedef duration<_Rep2, _Period2>           __dur2;
00418     typedef typename common_type<__dur1,__dur2>::type   __ct;
00419     return __ct(__lhs).count() / __ct(__rhs).count();
00420       }
00421 
00422     // DR 934.
00423     template<typename _Rep1, typename _Period, typename _Rep2>
00424       inline duration<typename __common_rep_type<_Rep1, typename
00425     enable_if<!__is_duration<_Rep2>::value, _Rep2>::type>::type, _Period>
00426       operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
00427       {
00428     typedef typename common_type<_Rep1, _Rep2>::type    __cr;
00429     return duration<__cr, _Period>(__d) %= __s;
00430       }
00431 
00432      template<typename _Rep1, typename _Period1,
00433           typename _Rep2, typename _Period2>
00434       inline typename common_type<duration<_Rep1, _Period1>,
00435                   duration<_Rep2, _Period2>>::type
00436       operator%(const duration<_Rep1, _Period1>& __lhs,
00437         const duration<_Rep2, _Period2>& __rhs)
00438       {
00439     typedef duration<_Rep1, _Period1>           __dur1;
00440     typedef duration<_Rep2, _Period2>           __dur2;
00441     typedef typename common_type<__dur1,__dur2>::type   __ct;
00442     return __ct(__lhs) %= __rhs;
00443       }
00444 
00445     // comparisons
00446     template<typename _Rep1, typename _Period1,
00447          typename _Rep2, typename _Period2>
00448       inline constexpr bool
00449       operator==(const duration<_Rep1, _Period1>& __lhs,
00450          const duration<_Rep2, _Period2>& __rhs)
00451       {
00452     typedef duration<_Rep1, _Period1>           __dur1;
00453     typedef duration<_Rep2, _Period2>           __dur2;
00454     typedef typename common_type<__dur1,__dur2>::type   __ct;
00455     return __ct(__lhs).count() == __ct(__rhs).count();
00456       }
00457 
00458     template<typename _Rep1, typename _Period1,
00459          typename _Rep2, typename _Period2>
00460       inline constexpr bool
00461       operator<(const duration<_Rep1, _Period1>& __lhs,
00462         const duration<_Rep2, _Period2>& __rhs)
00463       {
00464     typedef duration<_Rep1, _Period1>           __dur1;
00465     typedef duration<_Rep2, _Period2>           __dur2;
00466     typedef typename common_type<__dur1,__dur2>::type   __ct;
00467     return __ct(__lhs).count() < __ct(__rhs).count();
00468       }
00469 
00470     template<typename _Rep1, typename _Period1,
00471          typename _Rep2, typename _Period2>
00472       inline constexpr bool
00473       operator!=(const duration<_Rep1, _Period1>& __lhs,
00474          const duration<_Rep2, _Period2>& __rhs)
00475       { return !(__lhs == __rhs); }
00476 
00477     template<typename _Rep1, typename _Period1,
00478          typename _Rep2, typename _Period2>
00479       inline constexpr bool
00480       operator<=(const duration<_Rep1, _Period1>& __lhs,
00481          const duration<_Rep2, _Period2>& __rhs)
00482       { return !(__rhs < __lhs); }
00483 
00484     template<typename _Rep1, typename _Period1,
00485          typename _Rep2, typename _Period2>
00486       inline constexpr bool
00487       operator>(const duration<_Rep1, _Period1>& __lhs,
00488         const duration<_Rep2, _Period2>& __rhs)
00489       { return __rhs < __lhs; }
00490 
00491     template<typename _Rep1, typename _Period1,
00492          typename _Rep2, typename _Period2>
00493       inline constexpr bool
00494       operator>=(const duration<_Rep1, _Period1>& __lhs,
00495          const duration<_Rep2, _Period2>& __rhs)
00496       { return !(__lhs < __rhs); }
00497 
00498     /// nanoseconds
00499     typedef duration<int64_t, nano>     nanoseconds;
00500 
00501     /// microseconds
00502     typedef duration<int64_t, micro>    microseconds;
00503 
00504     /// milliseconds
00505     typedef duration<int64_t, milli>    milliseconds;
00506 
00507     /// seconds
00508     typedef duration<int64_t>       seconds;
00509 
00510     /// minutes
00511     typedef duration<int, ratio< 60>>   minutes;
00512 
00513     /// hours
00514     typedef duration<int, ratio<3600>>  hours;
00515 
00516     /// time_point
00517     template<typename _Clock, typename _Dur>
00518       struct time_point
00519       {
00520     typedef _Clock                      clock;
00521     typedef _Dur                        duration;
00522     typedef typename duration::rep              rep;
00523     typedef typename duration::period           period;
00524 
00525     constexpr time_point() : __d(duration::zero())
00526     { }
00527 
00528     constexpr explicit time_point(const duration& __dur)
00529     : __d(__dur)
00530     { }
00531 
00532     // conversions
00533     template<typename _Dur2>
00534       constexpr time_point(const time_point<clock, _Dur2>& __t)
00535       : __d(__t.time_since_epoch())
00536       { }
00537 
00538     // observer
00539     constexpr duration
00540     time_since_epoch() const
00541     { return __d; }
00542 
00543     // arithmetic
00544     time_point&
00545     operator+=(const duration& __dur)
00546     {
00547       __d += __dur;
00548       return *this;
00549     }
00550 
00551     time_point&
00552     operator-=(const duration& __dur)
00553     {
00554       __d -= __dur;
00555       return *this;
00556     }
00557 
00558     // special values
00559     static constexpr time_point
00560     min()
00561     { return time_point(duration::min()); }
00562 
00563     static constexpr time_point
00564     max()
00565     { return time_point(duration::max()); }
00566 
00567       private:
00568     duration __d;
00569       };
00570 
00571     /// time_point_cast
00572     template<typename _ToDur, typename _Clock, typename _Dur>
00573       inline constexpr typename enable_if<__is_duration<_ToDur>::value,
00574                 time_point<_Clock, _ToDur>>::type
00575       time_point_cast(const time_point<_Clock, _Dur>& __t)
00576       {
00577     typedef time_point<_Clock, _ToDur>          __time_point;
00578     return __time_point(duration_cast<_ToDur>(__t.time_since_epoch()));
00579       }
00580 
00581     template<typename _Clock, typename _Dur1,
00582          typename _Rep2, typename _Period2>
00583       inline time_point<_Clock,
00584     typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
00585       operator+(const time_point<_Clock, _Dur1>& __lhs,
00586         const duration<_Rep2, _Period2>& __rhs)
00587       {
00588     typedef duration<_Rep2, _Period2>           __dur2;
00589     typedef typename common_type<_Dur1,__dur2>::type    __ct;
00590     typedef time_point<_Clock, __ct>            __time_point;
00591     return __time_point(__lhs) += __rhs;
00592       }
00593 
00594     template<typename _Rep1, typename _Period1,
00595          typename _Clock, typename _Dur2>
00596       inline time_point<_Clock,
00597     typename common_type<duration<_Rep1, _Period1>, _Dur2>::type>
00598       operator+(const duration<_Rep1, _Period1>& __lhs,
00599         const time_point<_Clock, _Dur2>& __rhs)
00600       { return __rhs + __lhs; }
00601 
00602     template<typename _Clock, typename _Dur1,
00603          typename _Rep2, typename _Period2>
00604       inline time_point<_Clock,
00605     typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
00606       operator-(const time_point<_Clock, _Dur1>& __lhs,
00607         const duration<_Rep2, _Period2>& __rhs)
00608       { return __lhs + (-__rhs); }
00609 
00610     template<typename _Clock, typename _Dur1, typename _Dur2>
00611       inline typename common_type<_Dur1, _Dur2>::type
00612       operator-(const time_point<_Clock, _Dur1>& __lhs,
00613         const time_point<_Clock, _Dur2>& __rhs)
00614       { return __lhs.time_since_epoch() - __rhs.time_since_epoch(); }
00615 
00616     template<typename _Clock, typename _Dur1, typename _Dur2>
00617       inline constexpr bool
00618       operator==(const time_point<_Clock, _Dur1>& __lhs,
00619          const time_point<_Clock, _Dur2>& __rhs)
00620       { return __lhs.time_since_epoch() == __rhs.time_since_epoch(); }
00621 
00622     template<typename _Clock, typename _Dur1, typename _Dur2>
00623       inline constexpr bool
00624       operator!=(const time_point<_Clock, _Dur1>& __lhs,
00625          const time_point<_Clock, _Dur2>& __rhs)
00626       { return !(__lhs == __rhs); }
00627 
00628     template<typename _Clock, typename _Dur1, typename _Dur2>
00629       inline constexpr bool
00630       operator<(const time_point<_Clock, _Dur1>& __lhs,
00631         const time_point<_Clock, _Dur2>& __rhs)
00632       { return  __lhs.time_since_epoch() < __rhs.time_since_epoch(); }
00633 
00634     template<typename _Clock, typename _Dur1, typename _Dur2>
00635       inline constexpr bool
00636       operator<=(const time_point<_Clock, _Dur1>& __lhs,
00637          const time_point<_Clock, _Dur2>& __rhs)
00638       { return !(__rhs < __lhs); }
00639 
00640     template<typename _Clock, typename _Dur1, typename _Dur2>
00641       inline constexpr bool
00642       operator>(const time_point<_Clock, _Dur1>& __lhs,
00643         const time_point<_Clock, _Dur2>& __rhs)
00644       { return __rhs < __lhs; }
00645 
00646     template<typename _Clock, typename _Dur1, typename _Dur2>
00647       inline constexpr bool
00648       operator>=(const time_point<_Clock, _Dur1>& __lhs,
00649          const time_point<_Clock, _Dur2>& __rhs)
00650       { return !(__lhs < __rhs); }
00651 
00652     /// system_clock
00653     struct system_clock
00654     {
00655 #ifdef _GLIBCXX_USE_CLOCK_REALTIME
00656       typedef chrono::nanoseconds                   duration;
00657 #elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
00658       typedef chrono::microseconds                  duration;
00659 #else
00660       typedef chrono::seconds                       duration;
00661 #endif
00662 
00663       typedef duration::rep                     rep;
00664       typedef duration::period                  period;
00665       typedef chrono::time_point<system_clock, duration>    time_point;
00666 
00667       static_assert(system_clock::duration::min()
00668             < system_clock::duration::zero(),
00669             "a clock's minimum duration cannot be less than its epoch");
00670 
00671       static constexpr bool is_monotonic = false;
00672 
00673       static time_point
00674       now() throw ();
00675 
00676       // Map to C API
00677       static std::time_t
00678       to_time_t(const time_point& __t)
00679       {
00680     return std::time_t(duration_cast<chrono::seconds>
00681                (__t.time_since_epoch()).count());
00682       }
00683 
00684       static time_point
00685       from_time_t(std::time_t __t)
00686       {
00687     typedef chrono::time_point<system_clock, seconds>   __from;
00688     return time_point_cast<system_clock::duration>
00689            (__from(chrono::seconds(__t)));
00690       }
00691     };
00692 
00693 #ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
00694     /// monotonic_clock
00695     struct monotonic_clock
00696     {
00697       typedef chrono::nanoseconds               duration;
00698       typedef duration::rep                 rep;
00699       typedef duration::period                  period;
00700       typedef chrono::time_point<monotonic_clock, duration>     time_point;
00701 
00702       static constexpr bool is_monotonic = true;
00703 
00704       static time_point
00705       now();
00706     };
00707 #else
00708     typedef system_clock monotonic_clock;
00709 #endif
00710 
00711     typedef system_clock high_resolution_clock;
00712 
00713   _GLIBCXX_END_NAMESPACE_VERSION
00714   } // namespace chrono
00715 
00716   // @} group chrono
00717 } // namespace
00718 
00719 #endif //_GLIBCXX_USE_C99_STDINT_TR1
00720 
00721 #endif //__GXX_EXPERIMENTAL_CXX0X__
00722 
00723 #endif //_GLIBCXX_CHRONO