]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/include/std/chrono
acinclude.m4: Update references to final C++11 standard.
[thirdparty/gcc.git] / libstdc++-v3 / include / std / chrono
1 // <chrono> -*- C++ -*-
2
3 // Copyright (C) 2008-2012 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24
25 /** @file include/chrono
26 * This is a Standard C++ Library header.
27 */
28
29 #ifndef _GLIBCXX_CHRONO
30 #define _GLIBCXX_CHRONO 1
31
32 #pragma GCC system_header
33
34 #ifndef __GXX_EXPERIMENTAL_CXX0X__
35 # include <bits/c++0x_warning.h>
36 #else
37
38 #include <ratio>
39 #include <type_traits>
40 #include <limits>
41 #include <ctime>
42
43 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
44
45 namespace std _GLIBCXX_VISIBILITY(default)
46 {
47 /**
48 * @defgroup chrono Time
49 * @ingroup utilities
50 *
51 * Classes and functions for time.
52 * @{
53 */
54
55 /** @namespace std::chrono
56 * @brief ISO C++ 2011 entities sub-namespace for time and date.
57 */
58 namespace chrono
59 {
60 _GLIBCXX_BEGIN_NAMESPACE_VERSION
61
62 template<typename _Rep, typename _Period = ratio<1>>
63 struct duration;
64
65 template<typename _Clock, typename _Dur = typename _Clock::duration>
66 struct time_point;
67
68 _GLIBCXX_END_NAMESPACE_VERSION
69 }
70
71 _GLIBCXX_BEGIN_NAMESPACE_VERSION
72 // 20.11.4.3 specialization of common_type (for duration)
73 template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
74 struct common_type<chrono::duration<_Rep1, _Period1>,
75 chrono::duration<_Rep2, _Period2>>
76 {
77 private:
78 typedef __static_gcd<_Period1::num, _Period2::num> __gcd_num;
79 typedef __static_gcd<_Period1::den, _Period2::den> __gcd_den;
80 typedef typename common_type<_Rep1, _Rep2>::type __cr;
81 typedef ratio<__gcd_num::value,
82 (_Period1::den / __gcd_den::value) * _Period2::den> __r;
83
84 public:
85 typedef chrono::duration<__cr, __r> type;
86 };
87
88 // 20.11.4.3 specialization of common_type (for time_point)
89 template<typename _Clock, typename _Dur1, typename _Dur2>
90 struct common_type<chrono::time_point<_Clock, _Dur1>,
91 chrono::time_point<_Clock, _Dur2>>
92 {
93 private:
94 typedef typename common_type<_Dur1, _Dur2>::type __ct;
95
96 public:
97 typedef chrono::time_point<_Clock, __ct> type;
98 };
99 _GLIBCXX_END_NAMESPACE_VERSION
100
101 namespace chrono
102 {
103 _GLIBCXX_BEGIN_NAMESPACE_VERSION
104
105 // Primary template for duration_cast impl.
106 template<typename _ToDur, typename _CF, typename _CR,
107 bool _NumIsOne = false, bool _DenIsOne = false>
108 struct __duration_cast_impl
109 {
110 template<typename _Rep, typename _Period>
111 static constexpr _ToDur
112 __cast(const duration<_Rep, _Period>& __d)
113 {
114 typedef typename _ToDur::rep __to_rep;
115 return _ToDur(static_cast<__to_rep>(static_cast<_CR>(__d.count())
116 * static_cast<_CR>(_CF::num)
117 / static_cast<_CR>(_CF::den)));
118 }
119 };
120
121 template<typename _ToDur, typename _CF, typename _CR>
122 struct __duration_cast_impl<_ToDur, _CF, _CR, true, true>
123 {
124 template<typename _Rep, typename _Period>
125 static constexpr _ToDur
126 __cast(const duration<_Rep, _Period>& __d)
127 {
128 typedef typename _ToDur::rep __to_rep;
129 return _ToDur(static_cast<__to_rep>(__d.count()));
130 }
131 };
132
133 template<typename _ToDur, typename _CF, typename _CR>
134 struct __duration_cast_impl<_ToDur, _CF, _CR, true, false>
135 {
136 template<typename _Rep, typename _Period>
137 static constexpr _ToDur
138 __cast(const duration<_Rep, _Period>& __d)
139 {
140 typedef typename _ToDur::rep __to_rep;
141 return _ToDur(static_cast<__to_rep>(
142 static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den)));
143 }
144 };
145
146 template<typename _ToDur, typename _CF, typename _CR>
147 struct __duration_cast_impl<_ToDur, _CF, _CR, false, true>
148 {
149 template<typename _Rep, typename _Period>
150 static constexpr _ToDur
151 __cast(const duration<_Rep, _Period>& __d)
152 {
153 typedef typename _ToDur::rep __to_rep;
154 return _ToDur(static_cast<__to_rep>(
155 static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num)));
156 }
157 };
158
159 template<typename _Tp>
160 struct __is_duration
161 : std::false_type
162 { };
163
164 template<typename _Rep, typename _Period>
165 struct __is_duration<duration<_Rep, _Period>>
166 : std::true_type
167 { };
168
169 /// duration_cast
170 template<typename _ToDur, typename _Rep, typename _Period>
171 constexpr typename enable_if<__is_duration<_ToDur>::value,
172 _ToDur>::type
173 duration_cast(const duration<_Rep, _Period>& __d)
174 {
175 typedef typename _ToDur::period __to_period;
176 typedef typename _ToDur::rep __to_rep;
177 typedef ratio_divide<_Period, __to_period> __cf;
178 typedef typename common_type<__to_rep, _Rep, intmax_t>::type
179 __cr;
180 typedef __duration_cast_impl<_ToDur, __cf, __cr,
181 __cf::num == 1, __cf::den == 1> __dc;
182 return __dc::__cast(__d);
183 }
184
185 /// treat_as_floating_point
186 template<typename _Rep>
187 struct treat_as_floating_point
188 : is_floating_point<_Rep>
189 { };
190
191 /// duration_values
192 template<typename _Rep>
193 struct duration_values
194 {
195 static constexpr _Rep
196 zero()
197 { return _Rep(0); }
198
199 static constexpr _Rep
200 max()
201 { return numeric_limits<_Rep>::max(); }
202
203 static constexpr _Rep
204 min()
205 { return numeric_limits<_Rep>::lowest(); }
206 };
207
208 template<typename T>
209 struct __is_ratio
210 : std::false_type
211 { };
212
213 template<intmax_t _Num, intmax_t _Den>
214 struct __is_ratio<ratio<_Num, _Den>>
215 : std::true_type
216 { };
217
218 /// duration
219 template<typename _Rep, typename _Period>
220 struct duration
221 {
222 typedef _Rep rep;
223 typedef _Period period;
224
225 static_assert(!__is_duration<_Rep>::value, "rep cannot be a duration");
226 static_assert(__is_ratio<_Period>::value,
227 "period must be a specialization of ratio");
228 static_assert(_Period::num > 0, "period must be positive");
229
230 // 20.11.5.1 construction / copy / destroy
231 constexpr duration() = default;
232
233 constexpr duration(const duration&) = default;
234
235 template<typename _Rep2, typename = typename
236 enable_if<is_convertible<_Rep2, rep>::value
237 && (treat_as_floating_point<rep>::value
238 || !treat_as_floating_point<_Rep2>::value)>::type>
239 constexpr explicit duration(const _Rep2& __rep)
240 : __r(static_cast<rep>(__rep)) { }
241
242 template<typename _Rep2, typename _Period2, typename = typename
243 enable_if<treat_as_floating_point<rep>::value
244 || (ratio_divide<_Period2, period>::den == 1
245 && !treat_as_floating_point<_Rep2>::value)>::type>
246 constexpr duration(const duration<_Rep2, _Period2>& __d)
247 : __r(duration_cast<duration>(__d).count()) { }
248
249 ~duration() = default;
250 duration& operator=(const duration&) = default;
251
252 // 20.11.5.2 observer
253 constexpr rep
254 count() const
255 { return __r; }
256
257 // 20.11.5.3 arithmetic
258 constexpr duration
259 operator+() const
260 { return *this; }
261
262 constexpr duration
263 operator-() const
264 { return duration(-__r); }
265
266 duration&
267 operator++()
268 {
269 ++__r;
270 return *this;
271 }
272
273 duration
274 operator++(int)
275 { return duration(__r++); }
276
277 duration&
278 operator--()
279 {
280 --__r;
281 return *this;
282 }
283
284 duration
285 operator--(int)
286 { return duration(__r--); }
287
288 duration&
289 operator+=(const duration& __d)
290 {
291 __r += __d.count();
292 return *this;
293 }
294
295 duration&
296 operator-=(const duration& __d)
297 {
298 __r -= __d.count();
299 return *this;
300 }
301
302 duration&
303 operator*=(const rep& __rhs)
304 {
305 __r *= __rhs;
306 return *this;
307 }
308
309 duration&
310 operator/=(const rep& __rhs)
311 {
312 __r /= __rhs;
313 return *this;
314 }
315
316 // DR 934.
317 template<typename _Rep2 = rep>
318 typename enable_if<!treat_as_floating_point<_Rep2>::value,
319 duration&>::type
320 operator%=(const rep& __rhs)
321 {
322 __r %= __rhs;
323 return *this;
324 }
325
326 template<typename _Rep2 = rep>
327 typename enable_if<!treat_as_floating_point<_Rep2>::value,
328 duration&>::type
329 operator%=(const duration& __d)
330 {
331 __r %= __d.count();
332 return *this;
333 }
334
335 // 20.11.5.4 special values
336 static constexpr duration
337 zero()
338 { return duration(duration_values<rep>::zero()); }
339
340 static constexpr duration
341 min()
342 { return duration(duration_values<rep>::min()); }
343
344 static constexpr duration
345 max()
346 { return duration(duration_values<rep>::max()); }
347
348 private:
349 rep __r;
350 };
351
352 template<typename _Rep1, typename _Period1,
353 typename _Rep2, typename _Period2>
354 constexpr typename common_type<duration<_Rep1, _Period1>,
355 duration<_Rep2, _Period2>>::type
356 operator+(const duration<_Rep1, _Period1>& __lhs,
357 const duration<_Rep2, _Period2>& __rhs)
358 {
359 typedef duration<_Rep1, _Period1> __dur1;
360 typedef duration<_Rep2, _Period2> __dur2;
361 typedef typename common_type<__dur1,__dur2>::type __cd;
362 return __cd(__cd(__lhs).count() + __cd(__rhs).count());
363 }
364
365 template<typename _Rep1, typename _Period1,
366 typename _Rep2, typename _Period2>
367 constexpr typename common_type<duration<_Rep1, _Period1>,
368 duration<_Rep2, _Period2>>::type
369 operator-(const duration<_Rep1, _Period1>& __lhs,
370 const duration<_Rep2, _Period2>& __rhs)
371 {
372 typedef duration<_Rep1, _Period1> __dur1;
373 typedef duration<_Rep2, _Period2> __dur2;
374 typedef typename common_type<__dur1,__dur2>::type __cd;
375 return __cd(__cd(__lhs).count() - __cd(__rhs).count());
376 }
377
378 template<typename _Rep1, typename _Rep2, bool =
379 is_convertible<_Rep2,
380 typename common_type<_Rep1, _Rep2>::type>::value>
381 struct __common_rep_type { };
382
383 template<typename _Rep1, typename _Rep2>
384 struct __common_rep_type<_Rep1, _Rep2, true>
385 { typedef typename common_type<_Rep1, _Rep2>::type type; };
386
387 template<typename _Rep1, typename _Period, typename _Rep2>
388 constexpr
389 duration<typename __common_rep_type<_Rep1, _Rep2>::type, _Period>
390 operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
391 {
392 typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
393 __cd;
394 return __cd(__cd(__d).count() * __s);
395 }
396
397 template<typename _Rep1, typename _Rep2, typename _Period>
398 constexpr
399 duration<typename __common_rep_type<_Rep2, _Rep1>::type, _Period>
400 operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
401 { return __d * __s; }
402
403 template<typename _Rep1, typename _Period, typename _Rep2>
404 constexpr duration<typename __common_rep_type<_Rep1, typename
405 enable_if<!__is_duration<_Rep2>::value, _Rep2>::type>::type, _Period>
406 operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
407 {
408 typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
409 __cd;
410 return __cd(__cd(__d).count() / __s);
411 }
412
413 template<typename _Rep1, typename _Period1,
414 typename _Rep2, typename _Period2>
415 constexpr typename common_type<_Rep1, _Rep2>::type
416 operator/(const duration<_Rep1, _Period1>& __lhs,
417 const duration<_Rep2, _Period2>& __rhs)
418 {
419 typedef duration<_Rep1, _Period1> __dur1;
420 typedef duration<_Rep2, _Period2> __dur2;
421 typedef typename common_type<__dur1,__dur2>::type __cd;
422 return __cd(__lhs).count() / __cd(__rhs).count();
423 }
424
425 // DR 934.
426 template<typename _Rep1, typename _Period, typename _Rep2>
427 constexpr duration<typename __common_rep_type<_Rep1, typename
428 enable_if<!__is_duration<_Rep2>::value, _Rep2>::type>::type, _Period>
429 operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
430 {
431 typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
432 __cd;
433 return __cd(__cd(__d).count() % __s);
434 }
435
436 template<typename _Rep1, typename _Period1,
437 typename _Rep2, typename _Period2>
438 constexpr typename common_type<duration<_Rep1, _Period1>,
439 duration<_Rep2, _Period2>>::type
440 operator%(const duration<_Rep1, _Period1>& __lhs,
441 const duration<_Rep2, _Period2>& __rhs)
442 {
443 typedef duration<_Rep1, _Period1> __dur1;
444 typedef duration<_Rep2, _Period2> __dur2;
445 typedef typename common_type<__dur1,__dur2>::type __cd;
446 return __cd(__cd(__lhs).count() % __cd(__rhs).count());
447 }
448
449 // comparisons
450 template<typename _Rep1, typename _Period1,
451 typename _Rep2, typename _Period2>
452 constexpr bool
453 operator==(const duration<_Rep1, _Period1>& __lhs,
454 const duration<_Rep2, _Period2>& __rhs)
455 {
456 typedef duration<_Rep1, _Period1> __dur1;
457 typedef duration<_Rep2, _Period2> __dur2;
458 typedef typename common_type<__dur1,__dur2>::type __ct;
459 return __ct(__lhs).count() == __ct(__rhs).count();
460 }
461
462 template<typename _Rep1, typename _Period1,
463 typename _Rep2, typename _Period2>
464 constexpr bool
465 operator<(const duration<_Rep1, _Period1>& __lhs,
466 const duration<_Rep2, _Period2>& __rhs)
467 {
468 typedef duration<_Rep1, _Period1> __dur1;
469 typedef duration<_Rep2, _Period2> __dur2;
470 typedef typename common_type<__dur1,__dur2>::type __ct;
471 return __ct(__lhs).count() < __ct(__rhs).count();
472 }
473
474 template<typename _Rep1, typename _Period1,
475 typename _Rep2, typename _Period2>
476 constexpr bool
477 operator!=(const duration<_Rep1, _Period1>& __lhs,
478 const duration<_Rep2, _Period2>& __rhs)
479 { return !(__lhs == __rhs); }
480
481 template<typename _Rep1, typename _Period1,
482 typename _Rep2, typename _Period2>
483 constexpr bool
484 operator<=(const duration<_Rep1, _Period1>& __lhs,
485 const duration<_Rep2, _Period2>& __rhs)
486 { return !(__rhs < __lhs); }
487
488 template<typename _Rep1, typename _Period1,
489 typename _Rep2, typename _Period2>
490 constexpr bool
491 operator>(const duration<_Rep1, _Period1>& __lhs,
492 const duration<_Rep2, _Period2>& __rhs)
493 { return __rhs < __lhs; }
494
495 template<typename _Rep1, typename _Period1,
496 typename _Rep2, typename _Period2>
497 constexpr bool
498 operator>=(const duration<_Rep1, _Period1>& __lhs,
499 const duration<_Rep2, _Period2>& __rhs)
500 { return !(__lhs < __rhs); }
501
502 /// nanoseconds
503 typedef duration<int64_t, nano> nanoseconds;
504
505 /// microseconds
506 typedef duration<int64_t, micro> microseconds;
507
508 /// milliseconds
509 typedef duration<int64_t, milli> milliseconds;
510
511 /// seconds
512 typedef duration<int64_t> seconds;
513
514 /// minutes
515 typedef duration<int, ratio< 60>> minutes;
516
517 /// hours
518 typedef duration<int, ratio<3600>> hours;
519
520 /// time_point
521 template<typename _Clock, typename _Dur>
522 struct time_point
523 {
524 typedef _Clock clock;
525 typedef _Dur duration;
526 typedef typename duration::rep rep;
527 typedef typename duration::period period;
528
529 constexpr time_point() : __d(duration::zero())
530 { }
531
532 constexpr explicit time_point(const duration& __dur)
533 : __d(__dur)
534 { }
535
536 // conversions
537 template<typename _Dur2>
538 constexpr time_point(const time_point<clock, _Dur2>& __t)
539 : __d(__t.time_since_epoch())
540 { }
541
542 // observer
543 constexpr duration
544 time_since_epoch() const
545 { return __d; }
546
547 // arithmetic
548 time_point&
549 operator+=(const duration& __dur)
550 {
551 __d += __dur;
552 return *this;
553 }
554
555 time_point&
556 operator-=(const duration& __dur)
557 {
558 __d -= __dur;
559 return *this;
560 }
561
562 // special values
563 static constexpr time_point
564 min()
565 { return time_point(duration::min()); }
566
567 static constexpr time_point
568 max()
569 { return time_point(duration::max()); }
570
571 private:
572 duration __d;
573 };
574
575 /// time_point_cast
576 template<typename _ToDur, typename _Clock, typename _Dur>
577 constexpr typename enable_if<__is_duration<_ToDur>::value,
578 time_point<_Clock, _ToDur>>::type
579 time_point_cast(const time_point<_Clock, _Dur>& __t)
580 {
581 typedef time_point<_Clock, _ToDur> __time_point;
582 return __time_point(duration_cast<_ToDur>(__t.time_since_epoch()));
583 }
584
585 template<typename _Clock, typename _Dur1,
586 typename _Rep2, typename _Period2>
587 constexpr time_point<_Clock,
588 typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
589 operator+(const time_point<_Clock, _Dur1>& __lhs,
590 const duration<_Rep2, _Period2>& __rhs)
591 {
592 typedef duration<_Rep2, _Period2> __dur2;
593 typedef typename common_type<_Dur1,__dur2>::type __ct;
594 typedef time_point<_Clock, __ct> __time_point;
595 return __time_point(__lhs.time_since_epoch() + __rhs);
596 }
597
598 template<typename _Rep1, typename _Period1,
599 typename _Clock, typename _Dur2>
600 constexpr time_point<_Clock,
601 typename common_type<duration<_Rep1, _Period1>, _Dur2>::type>
602 operator+(const duration<_Rep1, _Period1>& __lhs,
603 const time_point<_Clock, _Dur2>& __rhs)
604 {
605 typedef duration<_Rep1, _Period1> __dur1;
606 typedef typename common_type<__dur1,_Dur2>::type __ct;
607 typedef time_point<_Clock, __ct> __time_point;
608 return __time_point(__rhs.time_since_epoch() + __lhs);
609 }
610
611 template<typename _Clock, typename _Dur1,
612 typename _Rep2, typename _Period2>
613 constexpr time_point<_Clock,
614 typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
615 operator-(const time_point<_Clock, _Dur1>& __lhs,
616 const duration<_Rep2, _Period2>& __rhs)
617 {
618 typedef duration<_Rep2, _Period2> __dur2;
619 typedef typename common_type<_Dur1,__dur2>::type __ct;
620 typedef time_point<_Clock, __ct> __time_point;
621 return __time_point(__lhs.time_since_epoch() -__rhs);
622 }
623
624 template<typename _Clock, typename _Dur1, typename _Dur2>
625 constexpr typename common_type<_Dur1, _Dur2>::type
626 operator-(const time_point<_Clock, _Dur1>& __lhs,
627 const time_point<_Clock, _Dur2>& __rhs)
628 { return __lhs.time_since_epoch() - __rhs.time_since_epoch(); }
629
630 template<typename _Clock, typename _Dur1, typename _Dur2>
631 constexpr bool
632 operator==(const time_point<_Clock, _Dur1>& __lhs,
633 const time_point<_Clock, _Dur2>& __rhs)
634 { return __lhs.time_since_epoch() == __rhs.time_since_epoch(); }
635
636 template<typename _Clock, typename _Dur1, typename _Dur2>
637 constexpr bool
638 operator!=(const time_point<_Clock, _Dur1>& __lhs,
639 const time_point<_Clock, _Dur2>& __rhs)
640 { return !(__lhs == __rhs); }
641
642 template<typename _Clock, typename _Dur1, typename _Dur2>
643 constexpr bool
644 operator<(const time_point<_Clock, _Dur1>& __lhs,
645 const time_point<_Clock, _Dur2>& __rhs)
646 { return __lhs.time_since_epoch() < __rhs.time_since_epoch(); }
647
648 template<typename _Clock, typename _Dur1, typename _Dur2>
649 constexpr bool
650 operator<=(const time_point<_Clock, _Dur1>& __lhs,
651 const time_point<_Clock, _Dur2>& __rhs)
652 { return !(__rhs < __lhs); }
653
654 template<typename _Clock, typename _Dur1, typename _Dur2>
655 constexpr bool
656 operator>(const time_point<_Clock, _Dur1>& __lhs,
657 const time_point<_Clock, _Dur2>& __rhs)
658 { return __rhs < __lhs; }
659
660 template<typename _Clock, typename _Dur1, typename _Dur2>
661 constexpr bool
662 operator>=(const time_point<_Clock, _Dur1>& __lhs,
663 const time_point<_Clock, _Dur2>& __rhs)
664 { return !(__lhs < __rhs); }
665
666 /// system_clock
667 struct system_clock
668 {
669 #ifdef _GLIBCXX_USE_CLOCK_REALTIME
670 typedef chrono::nanoseconds duration;
671 #elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
672 typedef chrono::microseconds duration;
673 #else
674 typedef chrono::seconds duration;
675 #endif
676
677 typedef duration::rep rep;
678 typedef duration::period period;
679 typedef chrono::time_point<system_clock, duration> time_point;
680
681 static_assert(system_clock::duration::min()
682 < system_clock::duration::zero(),
683 "a clock's minimum duration cannot be less than its epoch");
684
685 static constexpr bool is_steady = false;
686
687 static time_point
688 now() noexcept;
689
690 // Map to C API
691 static std::time_t
692 to_time_t(const time_point& __t) noexcept
693 {
694 return std::time_t(duration_cast<chrono::seconds>
695 (__t.time_since_epoch()).count());
696 }
697
698 static time_point
699 from_time_t(std::time_t __t) noexcept
700 {
701 typedef chrono::time_point<system_clock, seconds> __from;
702 return time_point_cast<system_clock::duration>
703 (__from(chrono::seconds(__t)));
704 }
705 };
706
707 #ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
708 /// steady_clock
709 struct steady_clock
710 {
711 typedef chrono::nanoseconds duration;
712 typedef duration::rep rep;
713 typedef duration::period period;
714 typedef chrono::time_point<steady_clock, duration> time_point;
715
716 static constexpr bool is_steady = true;
717
718 static time_point
719 now() noexcept;
720 };
721 #else
722 typedef system_clock steady_clock;
723 #endif
724
725 typedef system_clock high_resolution_clock;
726
727 _GLIBCXX_END_NAMESPACE_VERSION
728 } // namespace chrono
729
730 // @} group chrono
731 } // namespace
732
733 #endif //_GLIBCXX_USE_C99_STDINT_TR1
734
735 #endif //__GXX_EXPERIMENTAL_CXX0X__
736
737 #endif //_GLIBCXX_CHRONO