1[/
2 / Copyright (c) 2008 Howard Hinnant
3 / Copyright (c) 2006, 2008 Beman Dawes
4 / Copyright (c) 2009-2018 Vicente J. Botet Escriba
5 /
6 / Distributed under the Boost Software License, Version 1.0. (See accompanying
7 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 /]
9
10[library Boost.Chrono
11    [quickbook 1.5]
12    [version 2.0.8]
13    [authors [Hinnant, Howard]]
14    [authors [Dawes, Beman]]
15    [authors [Botet Escriba, Vicente J.]]
16    [copyright 2008 Howard Hinnant]
17    [copyright 2006, 2008 Beman Dawes]
18    [copyright 2009-2013 Vicente J. Botet Escriba]
19    [category utilities system]
20    [id chrono]
21    [dirname chrono]
22    [purpose
23        Useful time utilities.
24    ]
25    [license
26        Distributed under the Boost Software License, Version 1.0.
27        (See accompanying file LICENSE_1_0.txt or copy at
28        [@http://www.boost.org/LICENSE_1_0.txt])
29    ]
30]
31
32[/==================]
33[def __Boost_Chrono__ [*Boost.Chrono]]
34[def __Boost_Chrono [*Boost.Chrono]]
35
36[def __see_bellow__ ['see bellow]]
37
38[/===============================================]
39[def __inherit [*Inherits:]]
40[def __std_ref [*C++ Standard Reference:]]
41[def __header [*Header:]]
42[def __compat [*Compiler Compatibility:]]
43[def __examples [*Examples:]]
44[def __example [*Example:]]
45[def __type [*type:]]
46[def __returns [*Returns:]]
47[def __return_type [*Return Type:]]
48[def __throws [*Throws:]]
49[def __remarks [*Remarks:]]
50[def __effects [*Effects:]]
51[def __post_conditions [*Post Conditions:]]
52[def __post_condition [*Post Conditions:]]
53[def __postcondition [*Post Conditions:]]
54[def __pre_conditions [*Pre Conditions:]]
55[def __precondition [*Pre Conditions:]]
56[def __requires [*Requires:]]
57[def __params [*Parameters:]]
58[template param [p] [*[p]:]]
59
60[template mu[]'''μ'''] [/  Greek small letter mu]
61[template plusminus[]'''±'''] [/  ? plus or minus sign]
62
63[def __mus [mu]s]
64
65[/===============================================]
66[def __common_type `common_type`]
67
68
69[/===============================================]
70[def __ratio `ratio`]
71
72[def __ratio_add `ratio_add`]
73[def __ratio_subtract `ratio_subtract`]
74[def __ratio_multiply `ratio_multiply`]
75[def __ratio_divide `ratio_divide`]
76
77
78[def __ratio_equal `ratio_equal`]
79[def __ratio_not_equal `ratio_not_equal`]
80[def __ratio_less `ratio_less`]
81[def __ratio_less_equal `ratio_less_equal`]
82[def __ratio_greater `ratio_greater`]
83[def __ratio_greater_equal `ratio_greater_equal`]
84
85[def __failbit `failbit`]
86
87
88[def __atto `atto`]
89[def __femto `femto`]
90[def __pico `pico`]
91[def __nano `nano`]
92[def __micro `micro`]
93[def __milli `milli`]
94[def __centi `centi`]
95[def __deci `deci`]
96[def __deca `deca`]
97[def __hecto `hecto`]
98[def __kilo `kilo`]
99[def __mega `mega`]
100[def __giga `giga`]
101[def __tera `tera`]
102[def __peta `peta`]
103[def __exa `exa`]
104
105
106[/==================]
107
108
109[template chrono_conf[link_text] [link chrono.reference.cpp0x.chrono_chrono_hpp.conf [link_text]]]
110
111[def __BOOST_CHRONO_HEADER_ONLY [link chrono.reference.cpp0x.chrono_chrono_hpp.conf.header_only `BOOST_CHRONO_HEADER_ONLY`]]
112
113[def __BOOST_CHRONO_USES_STATIC_ASSERT [chrono_conf `BOOST_CHRONO_USES_STATIC_ASSERT`]]
114[def __BOOST_CHRONO_USES_MPL_ASSERT [chrono_conf `BOOST_CHRONO_USES_MPL_ASSERT`]]
115[def __BOOST_CHRONO_USES_ARRAY_ASSERT [chrono_conf `BOOST_CHRONO_USES_ARRAY_ASSERT`]]
116
117[def __BOOST_CHRONO_HAS_CLOCK_STEADY [link chrono.reference.cpp0x.system_clocks_hpp.BOOST_CHRONO_HAS_CLOCK_STEADY `BOOST_CHRONO_HAS_CLOCK_STEADY`]]
118
119[def __BOOST_CHRONO_HAS_THREAD_CLOCK [link chrono.reference.other_clocks.thread_clock_hpp.BOOST_CHRONO_HAS_THREAD_CLOCK `BOOST_CHRONO_HAS_THREAD_CLOCK`]]
120
121
122
123[def __clock_req [link chrono.reference.cpp0x.clock `Clock`] requirements]
124[def __Clock [link chrono.reference.cpp0x.clock `Clock`]]
125[def __Clock [link chrono.reference.cpp0x.clock `Clock`'s]]
126[def __TrivialClock [link chrono.reference.cpp0x.clock `TrivialClock`]]
127
128[def __To [link chrono.reference.cpp0x.duration_hpp.duration `To`]]
129[def __ToDuration [link chrono.reference.cpp0x.duration_hpp.duration `ToDuration`]]
130[def __Duration [link chrono.reference.cpp0x.duration_hpp.duration `Duration`]]
131[def __Duration1 [link chrono.reference.cpp0x.duration_hpp.duration `Duration1`]]
132[def __Duration2 [link chrono.reference.cpp0x.duration_hpp.duration `Duration2`]]
133[def __duration [link chrono.reference.cpp0x.duration_hpp.duration `duration`]]
134[def __durations [link chrono.reference.cpp0x.duration_hpp.duration `duration`]s]
135[def __duration_s [link chrono.reference.cpp0x.duration_hpp.duration `duration`]'s]
136
137[def __duration__c_0 [link chrono.reference.cpp0x.duration_hpp.duration.duration_c_0 `duration`]]
138[def __duration__c_1 [link chrono.reference.cpp0x.duration_hpp.duration.duration_c_1 `duration`]]
139[def __duration__c_2 [link chrono.reference.cpp0x.duration_hpp.duration.duration_c_2 `duration`]]
140[def __duration__count [link chrono.reference.cpp0x.duration_hpp.duration.count `count`]]
141[def __duration__op_unary_plus [link chrono.reference.cpp0x.duration_hpp.duration.op_plus `operator+`]]
142[def __duration__op_unary_minus [link chrono.reference.cpp0x.duration_hpp.duration.op_minus `operator-`]]
143[def __duration__op_pre_inc [link chrono.reference.cpp0x.duration_hpp.duration.op_pre_inc `operator++`]]
144[def __duration__op_post_inc [link chrono.reference.cpp0x.duration_hpp.duration.op_post_inc `operator++`]]
145[def __duration__op_pre_dec [link chrono.reference.cpp0x.duration_hpp.duration.op_pre_dec `operator--`]]
146[def __duration__op_post_dec [link chrono.reference.cpp0x.duration_hpp.duration.op_post_dec `operator--`]]
147[def __duration__op_plus_eq [link chrono.reference.cpp0x.duration_hpp.duration.op_plus_eq `operator+=`]]
148[def __duration__op_minus_eq [link chrono.reference.cpp0x.duration_hpp.duration.op_minus_eq `operator-=`]]
149[def __duration__op_mult_eq [link chrono.reference.cpp0x.duration_hpp.duration.op_mult_eq `operator*=`]]
150[def __duration__op_div_eq [link chrono.reference.cpp0x.duration_hpp.duration.op_div_eq `operator/=`]]
151[def __duration__op_mod_eq [link chrono.reference.cpp0x.duration_hpp.duration.op_mod_eq `operator%=`]]
152[def __duration__op_mod_eq2 [link chrono.reference.cpp0x.duration_hpp.duration.op_mod_eq2 `operator%=`]]
153[def __duration__zero [link chrono.reference.cpp0x.duration_hpp.duration.zero `zero`]]
154[def __duration__min [link chrono.reference.cpp0x.duration_hpp.duration.min `min`]]
155[def __duration__max [link chrono.reference.cpp0x.duration_hpp.duration.max `max`]]
156[def __duration__op_plus_1 [link chrono.reference.cpp0x.duration_hpp.arith.duration__op_plus_1 `operator+`]]
157[def __duration__op_minus_1 [link chrono.reference.cpp0x.duration_hpp.arith.duration__op_minus_1 `operator-`]]
158[def __duration__op_mult_1 [link chrono.reference.cpp0x.duration_hpp.arith.duration__op_mult_1 `operator*`]]
159[def __duration__op_mult_2 [link chrono.reference.cpp0x.duration_hpp.arith.duration__op_mult_2 `operator*`]]
160[def __duration__op_div_1 [link chrono.reference.cpp0x.duration_hpp.arith.duration__op_div_1 `operator/`]]
161[def __duration__op_div_2 [link chrono.reference.cpp0x.duration_hpp.arith.duration__op_div_2 `operator/`]]
162[def __duration__op_div_3 [link chrono.reference.cpp0x.duration_hpp.arith.duration__op_div_3 `operator/`]]
163[def __duration__op_mod_1 [link chrono.reference.cpp0x.duration_hpp.arith.duration__op_mod_1 `operator%`]]
164[def __duration__op_mod_2 [link chrono.reference.cpp0x.duration_hpp.arith.duration__op_mod_2 `operator%`]]
165[def __duration__op_eq_1 [link chrono.reference.cpp0x.duration_hpp.cmp.duration__op_eq_1 `operator==`]]
166[def __duration__op_neq_1 [link chrono.reference.cpp0x.duration_hpp.cmp.duration__op_neq_1 `operator!=`]]
167[def __duration__op_lt_1 [link chrono.reference.cpp0x.duration_hpp.cmp.duration__op_lt_1 `operator<`]]
168[def __duration__op_leq_1 [link chrono.reference.cpp0x.duration_hpp.cmp.duration__op_leq_1 `operator<=`]]
169[def __duration__op_gt_1 [link chrono.reference.cpp0x.duration_hpp.cmp.duration__op_gt_1 `operator>`]]
170[def __duration__op_geq_1 [link chrono.reference.cpp0x.duration_hpp.cmp.duration__op_geq_1 `operator>=`]]
171
172
173
174[/==================]
175[def __time_point [link chrono.reference.cpp0x.time_point_hpp.time_point `time_point`]]
176[def __time_points [link chrono.reference.cpp0x.time_point_hpp.time_point `time_point`]s]
177[def __time_point_s [link chrono.reference.cpp0x.time_point_hpp.time_point `time_point`]'s]
178
179
180[def __time_point__c_1 [link chrono.reference.cpp0x.time_point_hpp.time_point.time_point_c_1 `time_point`]]
181[def __time_point__c_2 [link chrono.reference.cpp0x.time_point_hpp.time_point.time_point_c_2 `time_point`]]
182[def __time_point__c_3 [link chrono.reference.cpp0x.time_point_hpp.time_point.time_point_c_3 `time_point`]]
183[def __time_point__time_since_epoch [link chrono.reference.cpp0x.time_point_hpp.time_point.time_since_epoch `time_since_epoch`]]
184[def __time_point__op_unary_plus [link chrono.reference.cpp0x.time_point_hpp.time_point.op_unary_plus `operator+`]]
185[def __time_point__op_unary_minus [link chrono.reference.cpp0x.time_point_hpp.time_point.op_unary_minus `operator-`]]
186[def __time_point__op_pre_inc [link chrono.reference.cpp0x.time_point_hpp.time_point.op_pre_inc `operator++`]]
187[def __time_point__op_post_inc [link chrono.reference.cpp0x.time_point_hpp.time_point.op_post_inc `operator++`]]
188[def __time_point__op_pre_dec [link chrono.reference.cpp0x.time_point_hpp.time_point.op_pre_dec `operator--`]]
189[def __time_point__op_post_dec [link chrono.reference.cpp0x.time_point_hpp.time_point.op_post_dec `operator--`]]
190[def __time_point__op_plus_eq_1[link chrono.reference.cpp0x.time_point_hpp.time_point.op_plus_eq_1 `operator+=`]]
191[def __time_point__op_plus_eq_2[link chrono.reference.cpp0x.time_point_hpp.time_point.op_plus_eq_2 `operator+=`]]
192[def __time_point__op_minus_eq_1 [link chrono.reference.cpp0x.time_point_hpp.time_point.op_minus_eq_1 `operator-=`]]
193[def __time_point__op_minus_eq_2 [link chrono.reference.cpp0x.time_point_hpp.time_point.op_minus_eq_2 `operator-=`]]
194[def __time_point__min [link chrono.reference.cpp0x.time_point_hpp.time_point.min `min`]]
195[def __time_point__max [link chrono.reference.cpp0x.time_point_hpp.time_point.max `max`]]
196[def __time_point__op_plus_1 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_plus_1 `operator+`]]
197[def __time_point__op_plus_2 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_plus_2 `operator+`]]
198[def __time_point__op_minus_1 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_minus_1 `operator-`]]
199[def __time_point__op_minus_2 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_minus_2 `operator-`]]
200[def __time_point__op_mult_1 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_mult_1 `operator*`]]
201[def __time_point__op_mult_2 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_mult_2 `operator*`]]
202[def __time_point__op_div_1 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_div_1 `operator/`]]
203[def __time_point__op_div_2 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_div_2 `operator/`]]
204[def __time_point__op_div_3 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_div_3 `operator/`]]
205[def __time_point__op_mod_1 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_mod_1 `operator%`]]
206[def __time_point__op_mod_2 [link chrono.reference.cpp0x.time_point_hpp.arith.time_point__op_mod_2 `operator%`]]
207[def __time_point__op_eq [link chrono.reference.cpp0x.time_point_hpp.cmp.time_point__op_eq `operator==`]]
208[def __time_point__op_neq [link chrono.reference.cpp0x.time_point_hpp.cmp.time_point__op_neq `operator!=`]]
209[def __time_point__op_lt [link chrono.reference.cpp0x.time_point_hpp.cmp.time_point__op_lt `operator<`]]
210[def __time_point__op_leq [link chrono.reference.cpp0x.time_point_hpp.cmp.time_point__op_leq `operator<=`]]
211[def __time_point__op_gt [link chrono.reference.cpp0x.time_point_hpp.cmp.time_point__op_gt `operator>`]]
212[def __time_point__op_geq [link chrono.reference.cpp0x.time_point_hpp.cmp.time_point__op_geq `operator>=`]]
213
214[def __time_point_units [link chrono.reference.io.time_point_units_hpp.time_point_units `time_point_units`]]
215
216
217
218
219
220
221[/==================]
222[def __system_clock [link chrono.reference.cpp0x.system_clocks_hpp.system_clock `system_clock`]]
223[def __steady_clock [link chrono.reference.cpp0x.system_clocks_hpp.steady_clock `steady_clock`]]
224[def __high_resolution_clock [link chrono.reference.cpp0x.system_clocks_hpp.high_resolution_clock `high_resolution_clock`]]
225
226[/==================]
227
228[def __process_real_cpu_clock [link chrono.reference.other_clocks.process_cpu_clocks_hpp.process_real_cpu_clock `process_real_cpu_clock`]]
229[def __process_system_cpu_clock [link chrono.reference.other_clocks.process_cpu_clocks_hpp.process_system_cpu_clock `process_system_cpu_clock`]]
230[def __process_user_cpu_clock [link chrono.reference.other_clocks.process_cpu_clocks_hpp.process_user_cpu_clock `process_user_cpu_clock`]]
231[def __process_cpu_clock [link chrono.reference.other_clocks.process_cpu_clocks_hpp.process_cpu_clock `process_cpu_clock`]]
232[def __thread_clock [link chrono.reference.other_clocks.thread_clock_hpp.thread_clock `thread_clock`]]
233
234[/==================]
235[def __duration_cast [link chrono.reference.cpp0x.duration_hpp.duration_cast `duration_cast`]]
236[def __time_point_cast [link chrono.reference.cpp0x.time_point_hpp.time_point_cast `time_point_cast`]]
237
238
239[def __nanoseconds [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `nanoseconds`]]
240[def __microseconds [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `microseconds`]]
241[def __milliseconds [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `milliseconds`]]
242[def __seconds [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `seconds`]]
243[def __minutes [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `minutes`]]
244[def __hours [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `hours`]]
245
246[def __common_type_spe [link chrono.reference.cpp0x.duration_hpp.common_type_spe `common_type`]]
247
248[/==================]
249[def __treat_as_floating_point [link chrono.reference.cpp0x.duration_hpp.traits.treat_as_floating_point `treat_as_floating_point`]]
250[def __duration_values [link chrono.reference.cpp0x.duration_hpp.traits.duration_values `duration_values`]]
251[def __zero [link chrono.reference.cpp0x.duration_hpp.traits.duration_values.zero `zero`]]
252[def __max [link chrono.reference.cpp0x.duration_hpp.traits.duration_values.max `max`]]
253[def __min [link chrono.reference.cpp0x.duration_hpp.traits.duration_values.min `min`]]
254
255
256
257[/==================]
258
259[def __duration_punct [link chrono.reference.io_v1.chrono_io_hpp.duration_punct `duration_punct`]]
260[def __duration_punct__c1 [link chrono.reference.io_v1.chrono_io_hpp.duration_punct.c1 `duration_punct`]]
261[def __duration_punct__c2 [link chrono.reference.io_v1.chrono_io_hpp.duration_punct.c2 `duration_punct`]]
262[def __duration_punct__is_prefix_name [link chrono.reference.io_v1.chrono_io_hpp.duration_punct.is_prefix_name `is_prefix_name`]]
263[def __duration_punct__is_symbol_name [link chrono.reference.io_v1.chrono_io_hpp.duration_punct.is_symbol_name `is_symbol_name`]]
264[def __duration_punct__get_duration_style [link chrono.reference.io_v1.chrono_io_hpp.duration_punct.get_duration_style `get_duration_style`]]
265
266[def __duration_short [link chrono.reference.io_v1.chrono_io_hpp.manipulators `duration_short`]]
267[def __duration_long [link chrono.reference.io_v1.chrono_io_hpp.manipulators `duration_long`]]
268
269
270[def __duration_style [link chrono.reference.io.duration_style_hpp.duration_style `duration_style`]]
271[def __duration_style_type [link chrono.reference.io.duration_style_hpp.duration_style `duration_style`]]
272[def __prefix [link chrono.reference.io.duration_style_hpp.duration_style `prefix`]]
273[def __symbol [link chrono.reference.io.duration_style_hpp.duration_style `symbol`]]
274
275[def __symbol_format [link chrono.reference.io.duration_io_hpp.manipulators.symbol_format `symbol_format`]]
276[def __name_format [link chrono.reference.io.duration_io_hpp.manipulators.name_format `name_format`]]
277[def __duration_fmt [link chrono.reference.io.duration_io_hpp.manipulators.duration_fmt `duration_fmt`]]
278[def __duration_fmt__c1 [link chrono.reference.io.duration_io_hpp.manipulators.duration_fmt.c1 `duration_fmt`]]
279[def __duration_fmt__op_duration_style [link chrono.reference.io.duration_io_hpp.manipulators.duration_fmt.op_duration_style `operator duration_style`]]
280[def __duration_fmt__get_duration_style [link chrono.reference.io.duration_io_hpp.manipulators.duration_fmt.op_duration_style `get_duration_style`]]
281[def __duration_fmt__op_in [link chrono.reference.io.duration_io_hpp.manipulators.duration_fmt.op_in `operator >>`]]
282[def __duration_fmt__op_out [link chrono.reference.io.duration_io_hpp.manipulators.duration_fmt.op_out `operator <<`]]
283
284
285[def __duration_style_io_saver [link chrono.reference.io.ios_state_hpp.ioss.duration_style_io_saver `duration_style_io_saver`]]
286[def __duration_style_io_saver__c1 [link chrono.reference.io.ios_state_hpp.ioss.duration_style_io_saver.c1 `duration_style_io_saver`]]
287[def __duration_style_io_saver__c2 [link chrono.reference.io.ios_state_hpp.ioss.duration_style_io_saver.c2 `duration_style_io_saver`]]
288[def __duration_style_io_saver__d [link chrono.reference.io.ios_state_hpp.ioss.duration_style_io_saver.d `~duration_style_io_saver`]]
289[def __duration_style_io_saver__restore [link chrono.reference.io.ios_state_hpp.ioss.duration_style_io_saver.restore `restore`]]
290
291[def __get_duration_style [link chrono.reference.io.ios_state_hpp.sag.get_duration_style `get_duration_style`]]
292[def __set_duration_style [link chrono.reference.io.ios_state_hpp.sag.set_duration_style `set_duration_style`]]
293[def __get_timezone [link chrono.reference.io.ios_state_hpp.sag.get_timezone `get_timezone`]]
294[def __set_timezone [link chrono.reference.io.ios_state_hpp.sag.set_timezone `set_timezone`]]
295[def __get_time_fmt [link chrono.reference.io.ios_state_hpp.sag.get_time_fmt `get_time_fmt`]]
296[def __set_time_fmt [link chrono.reference.io.ios_state_hpp.sag.set_time_fmt `set_time_fmt`]]
297
298[def __duration__op_in [link chrono.reference.io.duration_io_hpp.streams.duration__op_in `operator >>`]]
299[def __duration__op_out [link chrono.reference.io.duration_io_hpp.streams.duration__op_out `operator <<`]]
300
301[def __duration_get [link chrono.reference.io.duration_get_hpp.duration_get `duration_get`]]
302[def __duration_get_c [link chrono.reference.io.duration_get_hpp.duration_get.c `duration_get`]]
303[def __duration_get_d [link chrono.reference.io.duration_get_hpp.duration_get.d `~duration_get`]]
304[def __duration_get_get [link chrono.reference.io.duration_get_hpp.duration_get.get `get`]]
305[def __duration_get_get2 [link chrono.reference.io.duration_get_hpp.duration_get.get2 `get`]]
306[def __duration_get_get_unit [link chrono.reference.io.duration_get_hpp.duration_get.get_unit `get_unit`]]
307[def __duration_get_get_value [link chrono.reference.io.duration_get_hpp.duration_get.get_value `get_value`]]
308
309[def __duration_put [link chrono.reference.io.duration_put_hpp.duration_put `duration_put`]]
310[def __duration_put_c [link chrono.reference.io.duration_put_hpp.duration_put.c `duration_put`]]
311[def __duration_put_d [link chrono.reference.io.duration_put_hpp.duration_put.d `~duration_put`]]
312[def __duration_put_put [link chrono.reference.io.duration_put_hpp.duration_put.put `put`]]
313[def __duration_put_put2 [link chrono.reference.io.duration_put_hpp.duration_put.put2 `put`]]
314[def __duration_put_put_unit [link chrono.reference.io.duration_put_hpp.duration_put.put_unit `put_unit`]]
315[def __duration_put_put_value [link chrono.reference.io.duration_put_hpp.duration_put.put_value `put_value`]]
316
317[def __duration_units [link chrono.reference.io.duration_units_hpp.duration_units `duration_units`]]
318[def __duration_units_c [link chrono.reference.io.duration_units_hpp.duration_units.c `duration_units`]]
319[def __duration_units_d [link chrono.reference.io.duration_units_hpp.duration_units.d `~duration_units`]]
320[def __duration_units_get_n_d_valid_units_start [link chrono.reference.io.duration_units_hpp.duration_units.get_n_d_valid_units_start `get_n_d_valid_units_start`]]
321[def __duration_units_get_n_d_valid_units_end [link chrono.reference.io.duration_units_hpp.duration_units.get_n_d_valid_units_end `get_n_d_valid_units_end`]]
322[def __duration_units_get_n_d_unit [link chrono.reference.io.duration_units_hpp.duration_units.get_n_d_unit `get_n_d_unit`]]
323[def __duration_units_do_get_n_d_unit [link chrono.reference.io.duration_units_hpp.duration_units.do_get_n_d_unit `do_get_n_d_unit`]]
324[def __duration_units_match_n_d_valid_unit [link chrono.reference.io.duration_units_hpp.duration_units.match_n_d_valid_unit `match_n_d_valid_unit`]]
325[def __duration_units_get_valid_units_start [link chrono.reference.io.duration_units_hpp.duration_units.get_valid_units_start `get_valid_units_start`]]
326[def __duration_units_get_valid_units_end [link chrono.reference.io.duration_units_hpp.duration_units.get_valid_units_end `get_valid_units_end`]]
327[def __duration_units_get_unit [link chrono.reference.io.duration_units_hpp.duration_units.get_unit `get_unit`]]
328[def __duration_units_do_get_unit [link chrono.reference.io.duration_units_hpp.duration_units.do_get_unit `do_get_unit`]]
329[def __duration_units_match_valid_unit [link chrono.reference.io.duration_units_hpp.duration_units.match_valid_unit `match_valid_unit`]]
330[def __duration_units_get_pattern [link chrono.reference.io.duration_units_hpp.duration_units.get_pattern `get_pattern`]]
331[def __duration_units_is_named_unit [link chrono.reference.io.duration_units_hpp.duration_units.is_named_unit `is_named_unit`]]
332[def __duration_units_do_is_named_unit [link chrono.reference.io.duration_units_hpp.duration_units.do_is_named_unit `do_is_named_unit`]]
333
334
335[/==================]
336
337[def __timezone [link chrono.reference.io.timezone_hpp.timezone `timezone`]]
338[def __utc [link chrono.reference.io.timezone_hpp.timezone `utc`]]
339[def __local [link chrono.reference.io.timezone_hpp.timezone `local`]]
340
341
342[def __time_fmt1 [link chrono.reference.io.time_point_io_hpp.manip.time_fmt1 `time_fmt`]]
343[def __time_fmt2 [link chrono.reference.io.time_point_io_hpp.manip.time_fmt2 `time_fmt`]]
344
345[def __timezone_io_saver [link chrono.reference.io.ios_state_hpp.ioss.timezone_io_saver `timezone_io_saver`]]
346[def __timezone_io_saver__c1 [link chrono.reference.io.ios_state_hpp.ioss.timezone_io_saver.c1 `timezone_io_saver`]]
347[def __timezone_io_saver__c2 [link chrono.reference.io.ios_state_hpp.ioss.timezone_io_saver.c2 `timezone_io_saver`]]
348[def __timezone_io_saver__d [link chrono.reference.io.ios_state_hpp.ioss.timezone_io_saver.d `~timezone_io_saver`]]
349[def __timezone_io_saver__restore [link chrono.reference.io.ios_state_hpp.ioss.timezone_io_saver.restore `restore`]]
350
351[def __time_fmt_io_saver [link chrono.reference.io.ios_state_hpp.ioss.time_fmt_io_saver `time_fmt_io_saver`]]
352[def __time_fmt_io_saver__c1 [link chrono.reference.io.ios_state_hpp.ioss.time_fmt_io_saver.c1 `time_fmt_io_saver`]]
353[def __time_fmt_io_saver__c2 [link chrono.reference.io.ios_state_hpp.ioss.time_fmt_io_saver.c2 `time_fmt_io_saver`]]
354[def __time_fmt_io_saver__d [link chrono.reference.io.ios_state_hpp.ioss.time_fmt_io_saver.d `~time_fmt_io_saver`]]
355[def __time_fmt_io_saver__restore [link chrono.reference.io.ios_state_hpp.ioss.time_fmt_io_saver.restore `restore`]]
356
357[/==================]
358
359[def __round [link chrono.reference.round.round_hpp `round`]]
360[def __ceil [link chrono.reference.round.ceil_hpp `ceil`]]
361[def __floor [link chrono.reference.round.floor_hpp `floor`]]
362
363[/===============]
364[section Overview]
365[/===============]
366
367[:["What is time, then? If nobody asks me, I know; if I have to explain it to someone who has asked me, I do not know."]]
368[:[*['-- Augustine ]]]
369
370
371[/====================================]
372[heading How to Use This Documentation]
373[/====================================]
374
375This documentation makes use of the following naming and formatting conventions.
376
377* Code is in `fixed width font` and is syntax-highlighted.
378* Replaceable text that you will need to supply is in [~italics].
379* Free functions are rendered in the code font followed by `()`, as in `free_function()`.
380* If a name refers to a class template, it is specified like this:   `class_template<>`; that is, it is in code font and its name is followed by `<>`   to indicate that it is a class template.
381* If a name refers to a function-like macro, it is specified like this: `MACRO()`;
382  that is, it is uppercase in code font and its name is followed by `()` to   indicate that it is a function-like macro. Object-like macros appear without the   trailing `()`.
383* Names that refer to /concepts/ in the generic programming sense are  specified in CamelCase.
384
385[note In addition, notes such as this one specify non-essential information that provides additional background or rationale.]
386
387Finally, you can mentally add the following to any code fragments in this document:
388
389    // Include all of Chrono files
390    #include <boost/chrono.hpp>
391
392[/=================]
393[section Motivation]
394[/=================]
395
396[heading Time]
397
398We all deal with time every day of our lives. We've intuitively known it since birth. Thus we are all very familiar with it and believe it to be a simple matter. The modeling of time in computer programs should be similarly simple. The unfortunate truth is that this perceived simplicity is only skin deep. Fortunately, we do not need a terribly complicated solution to meet the bulk of our needs. However, overly simplistic solutions can be dangerous and inefficient, and won't adapt as the computer industry evolves.
399
400__Boost_Chrono__ implements the new time facilities in C++11, as proposed in [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm [*N2661 - A Foundation to Sleep On]].  That document provides background and motivation for key design decisions and is the source of a good deal of information in this documentation.
401
402[/
403__Boost_Chrono__ proposes a solution that is precision neutral, with a very simple end user interface which supports multiple clocks, multiple precisions (both coarser and finer than we will ever need), separate types for points in time and time durations, efficiency, and compile-time enforced safety.
404]
405
406
407In addition to the clocks provided by the standard proposal, __Boost_Chrono__ provides specific process and thread clocks.
408
409
410[/
411See [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm [*N2661 - A Foundation to Sleep On]] which is very informative and provides motivation for key design decisions for __common_type, __ratio and `chrono`. This documentation contains a lot of extracts from this document.
412]
413
414[heading Wall clock versus system and user time]
415
416To make the timing facilities of Boost.Chrono more generally useful, the library provides a number of clocks that are thin wrappers around the operating system's process time API, thereby allowing the extraction of wall clock time, user CPU time, and system CPU time of the process.  Wall clock time is the sum of CPU time and system CPU time. (On POSIX-like systems, this relies on `times()`.  On Windows, it relies on `GetProcessTimes()`.)
417
418[/
419It is also helpful if such timing information is broken down into real (wall clock) time, CPU time spent by the user, and CPU time spent by the operating system servicing user requests.
420]
421
422[/
4233 concrete process clocks:
424
425# __process_real_cpu_clock,
426# __process_user_cpu_clock,
427# __process_system_cpu_clock
428
429providing a
430]
431
432[/__Boost_Chrono__ provides
433thin wrappers around the operating system's process timer API. For POSIX-like systems, that's the times() function, while for Windows, it's the GetProcessTimes() function.
434]
435
436[/These clocks capture the specific time unitarily. __Boost_Chrono__ provides also a clock __process_cpu_clock that captures the three times at once.
437]
438
439[endsect]
440
441[/==================]
442[section Description]
443[/==================]
444
445The __Boost_Chrono__ library provides:
446
447[heading Standard]
448
449* A means to represent time durations: managed by the generic __duration class . Examples of time durations include days, __minutes, __seconds  and __nanoseconds, which can be represented with a fixed number of clock ticks per unit. All of these units of time duration are united with a generic interface by the __duration facility.
450* A type for representing points in time: __time_point. A __time_point represents an epoch plus or minus a __duration. The library leaves epochs unspecified. A __time_point is associated with a /clock/.
451* Several clocks, some of which may not be available on a particular platform: __system_clock, __steady_clock and __high_resolution_clock. A clock is a pairing of a __time_point and __duration, and a function which returns a __time_point representing ['now].
452
453[heading Other clocks]
454
455To make the timing facilities more generally useful, __Boost_Chrono__ provides a number of clocks that are thin wrappers around the operating system's time APIs, thereby allowing the extraction of wall clock time, user CPU time, system CPU time spent by the process,
456
457* __process_real_cpu_clock, captures wall clock CPU time spent by the current process.
458* __process_user_cpu_clock, captures user-CPU time spent by the current process.
459* __process_system_cpu_clock, captures system-CPU time  spent by the current process.
460* A tuple-like class __process_cpu_clock, that captures real, user-CPU, and system-CPU process times together.
461* A __thread_clock thread steady clock giving the time spent by the current thread (when supported by a platform).
462
463
464[/It is also helpful if such timing information is broken down into real (wall clock) time, CPU time spent by the user, and CPU time spent by the operating system servicing user requests. process clocks provide a thin wrapper around the operating system's process timer API. For POSIX-like systems, that's the times() function, while for Windows, it's the GetProcessTimes() function.
465]
466
467Lastly, __Boost_Chrono__ includes [@http://www.boost.org/libs/typeof typeof] registration for __duration and __time_point to permit using emulated auto with C++03 compilers.
468
469[heading I/O]
470
471It provides I/O for __duration and __time_point. This I/O makes use of these types much more convenient. In following the "you only pay for what you use" philosophy, this extra functionality is located in a header separate from <boost/chrono/chrono.hpp>, namely <boost/chrono/chrono_io.hpp>.
472
473It builds on `<boost/ratio/ratio_io.hpp>` to provide readable and flexible formatting and parsing for types in `<boost/chrono.hpp>`.
474This textural representation uses [@http://en.wikipedia.org/wiki/SI_prefix#List_of_SI_prefixes SI prefixes] whenever possible.
475This makes it easy for `boost::milliseconds` to be represented by the text "milliseconds", or a hypothetical meter
476class to print out "millimeter".
477The __duration and the __time_point i/o can be customized through the new facets: __duration_units and __time_point_units.
478The user can specialize these facets so that the chrono i/o could be localizable.
479However Boost.Chrono doesn't provides a complete locale solution.
480
481`system_clock::time_point` I/O is proposed in terms of UTC timepoints, strongly guided by
482ISO 9899:1999, Programming languages - C, ISO 9945:2003, Information Technology - Portable Operating System Interface (POSIX) and
483ISO 8601:2004, Data elements and interchange formats - Information interchange - Representation of dates and times.
484
485[heading Rounding utilities]
486
487A few simple rounding utility functions for working with durations.
488
489[heading Caveat Emptor]
490
491The underlying clocks provided by operating systems are subject to many seemingly arbitrary policies and implementation irregularities. That's a polite way of saying they tend to be flakey, and each operating system or even each clock has its own cruel and unusual forms of flakiness. Don't bet the farm on their accuracy, unless you have become deeply familiar with exactly what the specific operating system is guaranteeing, which is often very little.
492
493[endsect]
494
495[endsect]
496
497
498[/==============================]
499[section:users_guide User's Guide]
500[/==============================]
501
502[/======================================]
503[section:getting_started Getting Started]
504[/======================================]
505
506[/======================================]
507[section:install Installing Chrono]
508[/======================================]
509
510[/=================================]
511[heading Getting __Boost_Chrono__ ]
512[/=================================]
513
514__Boost_Chrono__ is in the latest Boost release in the folder `/boost/chrono`.  Documentation, tests and examples folder are at `boost/libs/chrono/`.
515
516You can also access the latest (unstable?) state from the [@https://svn.boost.org/svn/boost-trunk Boost trunk] directories boost/chrono and libs/chrono. Just go to [@http://svn.boost.org/trac/boost/wiki/BoostSubversion here] and follow the instructions there for anonymous SVN access.
517
518
519[/==========================================]
520[heading Where to install Boost.Chrono? ]
521[/==========================================]
522
523The simple way is to decompress (or checkout from SVN) the files in your BOOST_ROOT directory.
524
525
526[/=================================]
527[heading Building Boost.Chrono ]
528[/=================================]
529
530__Boost_Chrono__ can be configured as a header-only library defining __BOOST_CHRONO_HEADER_ONLY.
531However Boost.Chrono depends on the non header-only library Boost.System, so that you will need to link with boost_system.
532
533Boost.System has an undocumented feature (use of macro BOOST_ERROR_CODE_HEADER_ONLY) to make it header only.
534
535If __BOOST_CHRONO_HEADER_ONLY is not defined you need to compile it and build the library before use, for example using:
536
537    bjam libs/chrono/build
538
539[/===================]
540[heading Requirements]
541[/===================]
542
543In particular, __Boost_Chrono__ depends on:
544
545[variablelist
546[
547    [[@http://www.boost.org/libs/config [*Boost.Config]]] [for configuration purposes, ...]
548]
549[
550    [[@http://www.boost.org/libs/exception [*Boost.Exception]]] [for throw_exception, ...]
551]
552[
553    [[@http://www.boost.org/libs/integer [*Boost.Integer]]] [for cstdint conformance, ...]
554]
555[
556    [[@http://www.boost.org/libs/mpl [*Boost.MPL]]] [for MPL Assert and bool, logical ...]
557]
558[
559    [[@http://www.boost.org/libs/operators [*Boost.Operators]]] [for operators, ...]
560]
561[
562    [[@http://www.boost.org/libs/ratio [*Boost.Ratio]]] [for ratio, milli, micro, ...]
563]
564[
565    [[@http://www.boost.org/libs/system [*Boost.System]]] [for error_code, ...]
566]
567[
568    [[@http://www.boost.org/libs/type_traits [*Boost.TypeTraits]]] [for is_base, is_convertible, common_type, ...]
569]
570[
571    [[@http://www.boost.org/libs/utility [*Boost.Utility/EnableIf]]] [for enable_if, ...]
572]
573]
574
575
576[/=========================================================]
577[heading Building an Executable that Uses Boost.Chrono ]
578[/=========================================================]
579
580In addition to link with the __Boost_Chrono__ library you need also to link with the [*Boost.System] library.
581If [*Boost.System] is configured defining BOOST_ERROR_CODE_HEADER_ONLY you will no need to link with it as the dependent part is header only then.
582
583
584[/=========================]
585[heading Exception safety ]
586[/=========================]
587
588All functions in the library are exception-neutral and provide strong guarantee of exception safety as long as the underlying parameters provide it.
589
590
591[/=====================]
592[heading Thread safety ]
593[/=====================]
594
595All functions in the library are thread-unsafe except when noted explicitly.
596
597As Boost.Chrono doesn't use mutable global variables the thread-safety analysis is limited to the access to each instance variable. It is not thread safe to use a function that modifies the access to a user variable if another can be reading or writing it.
598
599
600[/========================]
601[heading Tested compilers ]
602[/========================]
603
604The implementation will eventually work with most C++03 conforming compilers.
605Currently I use to test with on:
606
607Windows with
608
609* MSVC 10.0
610
611MinGW with
612
613* GCC 4.5.0
614* GCC 4.5.0 -std=c++0x
615* GCC 4.5.2
616* GCC 4.5.2 -std=c++0x
617* GCC 4.6.0
618* GCC 4.6.0 -std=c++0x
619* GCC 4.8.0
620* GCC 4.8.0 -std=c++0x
621
622Ubuntu with
623* GCC 4.4.6
624* GCC 4.4.6 -std=c++0x
625* GCC 4.5.4
626* GCC 4.5.4 -std=c++0x
627* GCC 4.6.1
628* GCC 4.6.1 -std=c++0x
629* Intel 12.1.3
630* Intel 12.1.3 -std=c++0x
631
632OsX with
633
634* GCC 4.1.2
635* GCC 4.6.2
636* GCC 4.6.2 -std=c++0x
637* GCC 4.7.0
638* GCC 4.7.0 -std=c++0x
639* GCC 4.7.1
640* GCC 4.7.1 -std=c++0x
641* GCC 4.7.2
642* GCC 4.7.2 -std=c++0x
643* GCC 4.8.0
644* GCC 4.8.0 -std=c++0x
645* GCC 4.8.1
646* GCC 4.8.1 -std=c++0x
647* clang 3.1
648* clang 3.1 -std=c++0x -stdlib=libc++
649* clang 3.2
650* clang 3.2 -std=c++11 -stdlib=libc++
651
652
653The committed code is tested with much more compilers. There are two compilers (VACPP and Borland) that don't provide the needed features.
654Other as Intel and Sun have some issues with i/o. While everything compiles and link correctly, there are some runtime issues I have not cached yet. See the regression tests for details.
655
656[note Please let us know how this works on other platforms/compilers.]
657
658[note Please send any questions, comments and bug reports to boost <at> lists <dot> boost <dot> org.]
659
660[endsect]
661[/====================]
662[section Hello World! ]
663[/====================]
664
665[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
666If all you want to do is to time a program's execution, here is a complete program:
667
668    #include <boost/chrono.hpp>
669    #include <cmath>
670
671    int main()
672    {
673        boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();
674
675        for ( long i = 0; i < 10000000; ++i )
676        std::sqrt( 123.456L ); // burn some time
677
678        boost::chrono::__duration<double> sec = boost::chrono::system_clock::now() - start;
679        std::cout << "took " << sec.count() << " seconds\n";
680        return 0;
681    }
682
683Output was:
684
685    took 0.832 seconds
686
687[endsect]
688
689[endsect]
690
691
692[section Tutorial]
693
694[section Duration]
695
696The __duration is the heart of this library. The interface that the user will see in everyday use is nearly identical to that of [*Boost.DateTime] time __durations authored by Jeff Garland, both in syntax and in behavior. This has been a very popular boost library for 7 years. There is an enormous positive history with this interface.
697
698The library consists of six units of time __duration:
699
700* __hours
701* __minutes
702* __seconds
703* __milliseconds
704* __microseconds
705* __nanoseconds
706
707These units were chosen as a subset of the boost library because they are the most common units used when sleeping, waiting on a condition variable, or waiting to obtain the lock on a mutex. Each of these units is nothing but a thin wrapper around a signed integral count. That is, when you construct __minutes`(3)`, all that happens is a `3` is stored inside `minutes`. When you construct __microseconds`(3)`, all that happens is a `3` is stored inside __microseconds.
708
709The only context in which these different types differ is when being converted to one another. At this time, unit-specific compile-time conversion constants are used to convert the source unit to the target unit. Only conversions from coarser units to finer units are allowed (in Boost). This restriction ensures that all conversions are always exact. That is, __microseconds can always represent any value __minutes has.
710
711In [*Boost.DateTime], these units are united via inheritance. __Boost_Chrono__ instead unites these units through the class template __duration. That is, in __Boost_Chrono__ all six of the above units are nothing but typedefs to different instantiations of __duration. This change from Boost.DateTime has a far reaching positive impact, while not changing the syntax of the everyday use at all.
712
713The most immediate positive impact is that the library can immediately generate any unit, with any precision it needs. This is sometimes necessary when doing comparisons or arithmetic between __durations of differing precision, assuming one wants the comparison and arithmetic to be exact.
714
715A secondary benefit is that by publishing the class template __duration interface, user code can very easily create __durations with any precision they desire. The __ratio utility is used to specify the precision, so as long as the precision can be expressed by a rational constant with respect to seconds, this framework can exactly represent it (one third of a second is no problem, and neither is one third of a __femto second). All of this utility and flexibility comes at no cost just by making use of the no-run-time-overhead __ratio facility.
716
717In Boost.DateTime, __hours does not have the same representation as __nanoseconds. The former is usually represented with a `long` whereas a `long long` is required for the latter. The reason for this is simply range. You don't need many hours to cover an extremely large range of time. But this isn't true of nanoseconds. Being able to reduce the sizeof overhead for some units when possible, can be a significant performance advantage.
718
719__Boost_Chrono__ continues, and generalizes that philosophy. Not only can one specify the precision of a __duration, one can also specify its representation. This can be any integral type, or even a floating-point type. Or it can be a user-defined type which emulates an arithmetic type. The six predefined units all use signed integral types as their representation. And they all have a minimum range of [plusminus] 292 years. __nanoseconds needs 64 bits to cover that range. __hours needs only 23 bits to cover that range.
720
721
722[section  So What Exactly is a `duration` and How Do I Use One?]
723
724A __duration has a representation and a tick period (precision).
725
726    template <class Rep, class Period = __ratio<1> > class duration;
727
728The representation is simply any arithmetic type, or an emulation of such a type. The representation stores a count of ticks. This count is the only data member stored in a __duration. If the representation is floating-point, it can store fractions of a tick to the precision of the representation. The tick period is represented by a __ratio and is encoded into the __duration_s type, instead of stored. The tick period only has an impact on the behavior of the __duration when a conversion between different __durations is attempted. The tick period is completely ignored when simply doing arithmetic among like __durations.
729
730__example
731
732    typedef boost::chrono::__duration<long, boost::ratio<60> > minutes;
733    minutes m1(3);                 // m1 stores 3
734    minutes m2(2);                 // m2 stores 2
735    minutes m3 = m1 + m2;          // m3 stores 5
736
737    typedef boost::chrono::__duration<long long, boost::micro> microseconds;
738    microseconds us1(3);           // us1 stores 3
739    microseconds us2(2);           // us2 stores 2
740    microseconds us3 = us1 + us2;  // us3 stores 5
741
742    microseconds us4 = m3 + us3;   // us4 stores 300000005
743
744In the final line of code above, there is an implicit conversion from minutes to microseconds, resulting in a relatively large number of microseconds.
745
746If you need to access the tick count within a __duration, there is a member `count()` which simply returns the stored tick count.
747
748    long long tc = us4.count();    // tc is 300000005
749
750These __duration_s have very simple, very predictable, and very observable behavior. After all, this is really nothing but the time-tested interface of Jeff's boost time __duration library (unified with templates instead of inheritance).
751
752[endsect]
753
754[section What Happens if I Assign `m3 + us3` to `minutes` Instead of `microseconds`?]
755
756    minutes m4 = m3 + us3;
757
758It won't compile! The rationale is that implicit truncation error should not be allowed to happen. If this were to compile, then `m4` would hold `5`, the same value as `m3`. The value associated with `us3` has been effectively ignored. This is similar to the problem of assigning a double to an `int`: the fractional part gets silently discarded.
759[endsect]
760
761[section But What if the Truncation Behavior is What I Want to Do?]
762
763There is a __duration_cast facility to explicitly ask for this behavior:
764
765    minutes m4 = boost::chrono::__duration_cast<minutes>(m3 + us3);  // m4.count() == 5
766
767In general, one can perform __duration arithmetic at will. If __duration_cast isn't used, and it compiles, the arithmetic is exact. If one wants to override this exact arithmetic behavior, __duration_cast can be used to explicitly specify that desire. The __duration_cast has the same efficiency as the implicit conversion, and will even be exact as often as it can.
768
769You can use __duration_cast`<>` to convert the __duration into whatever units you desire.  This facility will round down (truncate) if an exact conversion is not possible.  For example:
770
771    boost::chrono::__nanoseconds start;
772    boost::chrono::__nanoseconds end;
773    typedef boost::chrono::__milliseconds ms;
774    ms d = boost::chrono::__duration_cast<ms>(end - start);
775
776    // d now holds the number of milliseconds from start to end.
777
778    std::cout << ms.count() << "ms\n";
779
780We can convert to __nanoseconds, or some integral-based duration which __nanoseconds will always exactly convert to, then __duration_cast`<>` is unnecessary:
781
782    typedef boost::chrono::__nanoseconds ns;
783    ns d = end - start;
784    std::cout << ns.count() << "ns\n";
785
786If you need seconds with a floating-point representation you can also eliminate the __duration_cast`<>`:
787
788    typedef boost::chrono::__duration<double> sec;  // seconds, stored with a double
789    sec d = end - start;
790    std::cout << sec.count() << "s\n";
791
792If you're not sure if you need __duration_cast`<>` or not, feel free to try it without.  If the conversion is exact, or if the destination has a floating-point representation, it will compile: else it will not compile.
793
794
795If you need to use __duration_cast`<>`, but want to round up, instead of down when the conversion is inexact, here is a handy little helper function to do so.  Writing it is actually a good starter project for understanding __Boost_Chrono__:
796
797    template <class __ToDuration, class Rep, class Period>
798    ToDuration
799    round_up(boost::chrono::__duration<Rep, Period> d)
800    {
801        // first round down
802        ToDuration result = boost::chrono::__duration_cast<ToDuration>(d);
803        if (result < d)  // comparisons are *always* exact
804           ++result;     // increment by one tick period
805        return result;
806    }
807
808    typedef boost::chrono::__milliseconds ms;
809    ms d = round_up<ms>(end - start);
810    // d now holds the number of milliseconds from start to end, rounded up.
811    std::cout << ms.count() << "ms\n";
812
813[endsect]
814
815[section:round Rounding functions]
816
817
818__Boost_Chrono__ provides few simple rounding utility functions for working with durations.
819
820
821    // round down
822    template <class __To, class Rep, class Period>
823    To
824    floor(const duration<Rep, Period>& d)
825    {
826        return duration_cast<To>(d);
827    }
828
829    // round to nearest, to even on tie
830    template <class __To, class Rep, class Period>
831    To
832    round(const duration<Rep, Period>& d)
833    {
834        To t0 = duration_cast<To>(d);
835        To t1 = t0;
836        ++t1;
837        BOOST_AUTO(diff0, d - t0);
838        BOOST_AUTO(diff1, t1 - d);
839        if (diff0 == diff1)
840        {
841            if (t0.count() & 1)
842                return t1;
843            return t0;
844        }
845        else if (diff0 < diff1)
846            return t0;
847        return t1;
848    }
849    // round up
850    template <class __To, class Rep, class Period>
851    To
852    ceil(const duration<Rep, Period>& d)
853    {
854        To t = duration_cast<To>(d);
855        if (t < d)
856            ++t;
857        return t;
858    }
859
860
861The beauty of the chrono library is the ease and accuracy with which such conversions can be made. For example to convert from __milliseconds (`1/1000` of a second), to `1/30` of a second, one must multiply the milliseconds by `0.03`. It is common knowledge that you can't exactly represent `0.03` in a computer. Nevertheless round will exactly (with no round off error) detect a tie and round to even when this happens. The differences `diff0` and `diff1` are not approximate, but exact differences, even when `d` has the units of millisecond and `To` is `1/30` of a second. The unit of `diff0` and `diff1` is `1/3000` of a second which both millisecond and `1/30` of a second exactly convert to (with no truncation error).
862
863Similarly, the comparison `t < d` in __ceil is exact, even when there is no exact conversion between `t` and `d`.
864Example use of rounding functions
865
866    #include <iostream>
867    #include <boost/chrono/chrono_io.hpp>
868    #include <boost/chrono/floor.hpp>
869    #include <boost/chrono/round.hpp>
870    #include <boost/chrono/ceil.hpp>
871
872    int main()
873    {
874        using namespace boost::chrono;
875        milliseconds ms(2500);
876        std::cout << floor<seconds>(ms) << '\n';
877        std::cout << round<seconds>(ms) << '\n';
878        std::cout << ceil<seconds>(ms) << '\n';
879        ms = milliseconds(2516);
880        typedef duration<long, boost::ratio<1, 30> > frame_rate;
881        std::cout << floor<frame_rate>(ms) << '\n';
882        std::cout << round<frame_rate>(ms) << '\n';
883        std::cout << ceil<frame_rate>(ms) << '\n';
884
885        return 0;
886    }
887
888The output of this program should be
889
890    2 seconds
891    2 seconds
892    3 seconds
893    75 [1/30]seconds
894    75 [1/30]seconds
895    76 [1/30]seconds
896
897[endsect]
898
899[section Trafficking in floating-point Durations]
900
901I don't want to deal with writing `duration_cast` all over the place. I'm content with the precision of my floating-point representation.
902
903Not a problem. When the destination of a conversion has floating-point representation, all conversions are allowed to happen implicitly.
904
905    typedef boost::chrono::__duration<double, __ratio<60> > dminutes;
906    dminutes dm4 = m3 + us3;  // dm4.count() == 5.000000083333333
907
908[endsect]
909
910[section How Expensive is All of this?]
911
912If you were writing these conversions by hand, you could not make it more efficient. The use of __ratio ensures that all conversion constants are simplified as much as possible at compile-time. This usually results in the numerator or denominator of the conversion factor simplifying to `1`, and being subsequently ignored in converting the run-time values of the tick counts.
913
914[endsect]
915
916[section  How Complicated is it to Build a Function Taking a `duration` Parameter?]
917
918There are several options open to the user:
919
920* If the author of the function wants to accept any __duration, and is willing to work in floating-point __durations, he can simply use any floating-point __duration as the parameter:
921
922          void f(boost::chrono::duration<double> d)  // accept floating-point seconds
923          {
924              // d.count() == 3.e-6 when passed boost::chrono::microseconds(3)
925          }
926
927          f(boost::chrono::microseconds(3));
928
929* If the author of the function wants to traffic only in integral __durations, and is content with handling nothing finer than say nanoseconds (just as an example), he can simply specify nanoseconds as the parameter:
930
931          void f(boost::chrono::nanoseconds d)
932          {
933              // d.count() == 3000 when passed boost::chrono::microseconds(3)
934          }
935
936          f(boost::chrono::microseconds(3));
937
938In this design, if the client wants to pass in a floating-point __duration, or a __duration of finer precision than nanoseconds, then the client is responsible for choosing his own rounding mode in the conversion to nanoseconds.
939
940          boost::chrono::__duration<double> s(1./3);  // 1/3 of a second
941          f(boost::chrono::duration_cast<boost::chrono::nanoseconds>(s));  // round towards zero in conversion to nanoseconds
942
943In the example above, the client of f has chosen "round towards zero" as the desired rounding mode to nanoseconds. If the client has a __duration that won't exactly convert to nanoseconds, and fails to choose how the conversion will take place, the compiler will refuse the call:
944
945        f(s);  // does not compile
946
947* If the author of the function wants to accept any __duration, but wants to work with integral representations and wants to control the rounding mode internally, then he can template the function:
948
949        template <class Rep, class Period>
950        void f(boost::chrono::__duration<Rep, Period> d)
951        {
952            // convert d to nanoseconds, rounding up if it is not an exact conversion
953            boost::chrono::nanoseconds ns = boost::chrono::duration_cast<boost::chrono::nanoseconds>(d);
954            if (ns < d)
955                ++ns;
956            // ns.count() == 333333334 when passed 1/3 of a floating-point second
957        }
958
959          f(boost::chrono::__duration<double>(1./3));
960
961*  If the author in the example does not want to accept floating-point based __durations, he can enforce that behavior like so:
962
963        template <class Period>
964        void f(boost::chrono::__duration<long long, Period> d)
965        {
966            // convert d to nanoseconds, rounding up if it is not an exact conversion
967            boost::chrono::nanoseconds ns = boost::chrono::duration_cast<nanoseconds>(d);
968            if (ns < d)
969                ++ns;
970            // ns.count() == 333333334 when passed 333333333333 picoseconds
971        }
972        // About 1/3 of a second worth of picoseconds
973        f(boost::chrono::__duration<long long, boost::pico>(333333333333));
974
975Clients with floating-point __durations who want to use f will now have to convert to an integral __duration themselves before passing the result to f.
976
977In summary, the author of f has quite a bit of flexibility and control in the interface he wants to provide his clients with, and easy options for manipulating that __duration internal to his function.
978[endsect]
979
980[section Is it possible for the user to pass a __duration to a function with the units being ambiguous?]
981
982No. No matter which option the author of `f` chooses above, the following client code will not compile:
983
984    f(3);  // Will not compile, 3 is not implicitly convertible to any __duration
985
986[endsect]
987
988[section Can Durations Overflow?]
989
990This depend on the representation. The default typedefs uses a representation that don't handle overflows. The user can define his own representation that manage overflow as required by its application.
991
992[endsect]
993[endsect]
994
995[section Clocks]
996
997While __durations only have precision and representation to concern themselves, clocks and __time_points are intimately related and refer to one another. Because clocks are simpler to explain, we will do so first without fully explaining __time_points. Once clocks are introduced, it will be easier to then fill in what a __time_point is.
998
999A clock is a concept which bundles 3 things:
1000
1001# A concrete __duration type.
1002# A concrete __time_point type.
1003# A function called now() which returns the concrete __time_point.
1004
1005The standard defines three system-wide clocks that are associated to the computer time.
1006
1007* __system_clock represents system-wide realtime clock that can be synchronized with an external clock.
1008
1009* __steady_clock can not be changed explicitly and the time since the initial epoch increase in a steady way.
1010
1011* __high_resolution_clock intend to use the system-wide clock provided by the platform with the highest resolution.
1012
1013__Boost_Chrono__ provides them when supported by the underlying platform. A given platform may not be able to supply all three of these clocks.
1014
1015The library adds some clocks that are specific to a process or a thread, that is there is a clock per process or per thread.
1016
1017
1018The user is also able to easily create more clocks.
1019
1020Given a clock named Clock, it will have:
1021
1022    class Clock {
1023    public:
1024        typedef an arithmetic-like type        rep;
1025        typedef an instantiation of ratio      period;
1026        typedef boost::chrono::__duration<rep, period> __duration;
1027        typedef boost::chrono::__time_point<__Clock>     time_point;
1028        static constexpr bool is_steady =      true or false;
1029
1030        static time_point now();
1031    };
1032
1033One can get the current time from Clock with:
1034
1035    Clock::time_point t1 = Clock::now();
1036
1037And one can get the time __duration between two __time_points associated with Clock with:
1038
1039    Clock::duration d = Clock::now() - t1;
1040
1041And one can specify a past or future __time_point with:
1042
1043    Clock::time_point t2 = Clock::now() + d;
1044
1045Note how even if a particular clock becomes obsolete, the next clock in line will have the same API. There is no new learning curve to come up. The only source code changes will be simply changing the type of the clock. The same __duration and __time_point framework continues to work as new clocks are introduced. And multiple clocks are safely and easily handled within the same program.
1046
1047
1048[endsect]
1049
1050
1051[section Time Point]
1052
1053A __time_point represents a point in time, as opposed to a __duration of time. Another way of saying the same thing, is that a __time_point represents an epoch plus or minus a __duration. Examples of __time_points include:
1054
1055* 3 minutes after the computer booted.
1056* 03:14:07 UTC on Tuesday, January 19, 2038
1057* 20 milliseconds after I started that timer.
1058
1059In each of the examples above, a different epoch is implied. Sometimes an epoch has meaning for several millennia. Other times the meaning of an epoch is lost after a while (such as the start of a timer, or when the computer booted). However, if two __time_points are known to share the same epoch, they can be subtracted, yielding a valid __duration, even if the definition of the epoch no longer has meaning.
1060
1061In __Boost_Chrono__, an epoch is a purely abstract and unspecified concept. There is no type representing an epoch. It is simply an idea that relates (or doesn't) __time_points to a clock, and in the case that they share a clock, __time_points to one another. __time_points associated with different clocks are generally not interoperable unless the relationship between the epochs associated with each clock is known.
1062
1063[section  So What Exactly is a `time_point` and How Do I Use One?]
1064
1065A __time_point has a clock and a __duration.
1066
1067    template <class __Clock, class __Duration = typename Clock::duration> class __time_point;
1068
1069The __time_point's clock is not stored. It is simply embedded into the __time_point's type and serves two purposes:
1070
1071# Because __time_points originating from different clocks have different types, the compiler can be instructed to fail if incompatible __time_points are used in inappropriate ways.
1072# Given a __time_point, one often needs to compare that __time_point to "now". This is very simple as long as the __time_point knows what clock it is defined with respect to.
1073
1074A __time_point's __duration is stored as the only data member of the __time_point. Thus __time_points and their corresponding __duration have exactly the same layout. But they have very different meanings. For example, it is one thing to say I want to sleep for 3 minutes. It is a completely different thing to say I want to sleep until 3 minutes past the time I started that timer (unless you just happened to start that timer now). Both meanings (and options for sleeping) have great practical value in common use cases for sleeping, waiting on a condition variable, and waiting for a mutex's lock. These same concepts and tools are found (for example) in Ada.
1075
1076A timer example:
1077
1078    void f()
1079    {
1080        boost::chrono::steady_clock::time_point start = boost::chrono::steady_clock::now();
1081        g();
1082        h();
1083        __duration<double> sec = boost::chrono::steady_clock::now() - start;
1084        cout << "f() took " << sec.count() << " seconds\n";
1085    }
1086
1087Note that if one is using the __duration between two clock __time_points in a way where the precision of the __duration matters, it is good practice to convert the clock's  __duration to a known __duration. This insulates the code from future changes which may be made to the clock's  precision in the future. For example __steady_clock could easily be based on the clock speed of the cpu. When you upgrade to a faster machine, you do not want your code that assumed a certain tick period of this clock to start experiencing run-time failures because your timing code has silently changed meaning.
1088
1089A delay loop example:
1090
1091    // delay for at least 500 nanoseconds:
1092    auto go = boost::chrono::steady_clock::now() + boost::chrono::nanoseconds(500);
1093    while (boost::chrono::steady_clock::now() < go)
1094        ;
1095
1096The above code will delay as close as possible to half a microsecond, no matter what the precision of __steady_clock is. The more precise __steady_clock becomes, the more accurate will be the delay to 500 nanoseconds.
1097
1098
1099[endsect]
1100
1101
1102
1103[/
1104[section How to Define a Thread Clock]
1105
1106On posix systems for which the macro _POSIX_THREAD_CPUTIME is defined we can get the time associated to a specific thread.
1107
1108    class thread_clock {
1109    public:
1110        typedef __nanoseconds                          duration;
1111        typedef duration::rep                        rep;
1112        typedef duration::period                     period;
1113        typedef chrono::__time_point<thread_clock>    time_point;
1114        static constexpr bool is_steady =            BOOST_CHRONO_THREAD_CLOCK_IS_STEADY;
1115
1116        static time_point now( ) {
1117            // get the current thread
1118            pthread_t pth=pthread_self(void);
1119            // get the clock_id associated to the current thread
1120            clockid_t clock_id;
1121            pthread_getcpuclockid(pth, clock_id);
1122            // get the timespec associated to the thread clock
1123            struct timespec ts;
1124            if ( ::clock_gettime( clock_id, &ts ) )
1125            {
1126                boost::throw_exception(
1127                system::system_error( errno, system::system_category, "chrono::thread_clock" ));
1128            }
1129
1130            // transform to nanoseconds
1131            return time_point(duration(
1132                static_cast<thread_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
1133
1134        }
1135        static time_point now( system::error_code & ec ) {
1136            // get the current thread
1137            pthread_t pth=pthread_self(void);
1138            // get the clock_id associated to the current thread
1139            clockid_t clock_id;
1140            pthread_getcpuclockid(pth, clock_id);
1141            // get the timespec associated to the thread clock
1142            struct timespec ts;
1143            if ( ::clock_gettime( clock_id, &ts ) )
1144            {
1145              ec.assign( errno, system::system_category );
1146              return time_point();
1147            }
1148            ec.clear();
1149            // transform to nanoseconds
1150            return time_point(duration(
1151                static_cast<thread_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
1152        }
1153    };
1154
1155[endsect]
1156]
1157
1158
1159[endsect]
1160
1161[section Specific Clocks]
1162[section system_clock]
1163
1164__system_clock is useful when you need to correlate the time with a known epoch so you can convert it to a calendar time. Note the specific functions in the __system_clock class.
1165
1166
1167[endsect]
1168[section steady_clock]
1169
1170__steady_clock is useful when you need to wait for a specific amount of time. __steady_clock time can not be reset. As other steady clocks, it is usually based on the processor tick.
1171
1172Here is a polling solution, but it will probably be too inefficient:
1173
1174    boost::chrono::__steady_clock::time_point start= chrono::__steady_clock::now();
1175    boost::chrono::__steady_clock::duration delay= chrono::seconds(5);
1176    while (boost::chrono::__steady_clock::now() - start <= delay) {}
1177
1178[endsect]
1179
1180[section high_resolution_clock]
1181
1182When available, __high_resolution_clock is usually more expensive than the other system-wide clocks, so they are used only when the provided resolution is required to the application.
1183
1184[endsect]
1185
1186[section process_cpu_clock]
1187
1188Process and thread clocks are used usually to measure the time spent by code blocks, as a basic time-spent profiling of different blocks of code (Boost.Chrono.Stopwatch is a clear example of this use).
1189
1190[endsect]
1191
1192[section thread_clock]
1193
1194You can use __thread_clock whenever you want to measure the time spent by the current thread. For example:
1195
1196    boost::chrono::__thread_clock::time_point start=boost::chrono::__thread_clock::now();
1197    // ... do something ...
1198
1199    typedef boost::chrono::__milliseconds ms;
1200    ms d = boost::chrono::__thread_clock::now() - start;
1201    // d now holds the number of milliseconds from start to end.
1202    std::cout << ms.count() << "ms\n";
1203
1204If you need seconds with a floating-point representation you can do:
1205
1206    typedef boost::chrono::__duration<double> sec;  // seconds, stored with a double.
1207    sec d = end - start;
1208    std::cout << sec.count() << "s\n";
1209
1210If you would like to programmatically inspect `__thread_clock::duration`, you can get the representation type with `__thread_clock::rep`, and the tick period with `__thread_clock::period` (which should be a type __ratio which has nested values `__ratio::num` and `__ratio::den`).  The tick period of __thread_clock is `__thread_clock::period::num / __thread_clock::period::den` seconds: `1/1000000000` in this case (`1` billionth of a second), stored in a `long long`.
1211
1212[endsect]
1213[endsect]
1214
1215[section I/O]
1216
1217[section:duration_io duration]
1218
1219Any __duration can be streamed out to a `basic_ostream`. The run-time value of the __duration is formatted according to the rules and current format settings for __duration`::rep` get_duration_style and the durationpunct facet.
1220
1221the format is either
1222
1223  <value> <unit>
1224
1225or
1226
1227  <unit> <value>
1228
1229
1230
1231[warning Need to be changed
1232This is followed by a single space and then the compile-time unit name of the __duration. This unit name is built on the string returned from `ratio_string<>` and the data used to construct the __duration_punct which was inserted into the stream's locale. If a __duration_punct has not been inserted into the stream's locale, a default constructed __duration_punct will be added to the stream's locale.
1233
1234__duration unit names come in two varieties: long(prefix) and short(symbol). The default constructed __duration_punct provides names in the long(prefix) format. These names are English descriptions. Other languages are supported by constructing a __duration_punct with the proper spellings for "hours", "minutes" and "seconds", and their abbreviations (for the short format). The short or long format can be easily chosen by streaming a `duration_short()` or `duration_long()` manipulator respectively or using the parameterized manipulator `duration_fmt(duration_style::prefix)` or `duration_fmt(duration_style::symbol)`.
1235
1236]
1237__example
1238
1239    #include <iostream>
1240    #include <boost/chrono/chrono_io.hpp>
1241
1242    int main()
1243    {
1244        using namespace std;
1245        using namespace boost;
1246
1247        cout << "milliseconds(1) = "
1248             <<  boost::chrono::milliseconds(1) << '\n';
1249
1250        cout << "milliseconds(3) + microseconds(10) = "
1251             <<  boost::chrono::milliseconds(3) + boost::chrono::microseconds(10) << '\n';
1252
1253        cout << "hours(3) + minutes(10) = "
1254             <<  boost::chrono::hours(3) + boost::chrono::minutes(10) << '\n';
1255
1256        typedef boost::chrono::duration<long long, boost::ratio<1, 2500000000> > ClockTick;
1257        cout << "ClockTick(3) + boost::chrono::nanoseconds(10) = "
1258             <<  ClockTick(3) + boost::chrono::nanoseconds(10) << '\n';
1259
1260       // ...
1261        return 0;
1262    }
1263
1264The output could be
1265
1266    milliseconds(1) = 1 microsecond
1267    milliseconds(3) + microseconds(10) = 3010 microseconds
1268    hours(3) + minutes(10) = 190 minutes
1269    ClockTick(3) + nanoseconds(10) = 56 [1/5000000000]seconds
1270
1271    Set cout to use short names:
1272    milliseconds(3) + microseconds(10) = 3010 __mus
1273    hours(3) + minutes(10) = 190 m
1274    ClockTick(3) + nanoseconds(10) = 56 [1/5000000000]s
1275
1276    system_clock::now() = 129387415616250000 [1/10000000]s since Jan 1, 1970
1277    monotonic_clock::now() = 37297387636417 ns since boot
1278
1279    Set cout to use long names:
1280    high_resolution_clock::now() = 37297387655134 nanoseconds since boot
1281
1282As can be seen, each duration type can be streamed without having to manually stream the compile-time units after the run-time value. And when the compile-time unit is known to be a "common unit", English names are used. For "uncommon units" a unit name is composed from the reduced numerator and denominator of the associated __ratio. Whatever stream/locale settings are set for `duration::rep` are used for the value. Additionally, when the value is 1, singular forms for the units are used.
1283
1284Sometimes it is desired to shorten these names by using the SI symbols instead of SI prefixes. This can be accomplished with the use of the __symbol_format manipulator [footnote __duration_short in V1]:
1285
1286        cout << "\nSet cout to use short names:\n";
1287        cout << boost::chrono::symbol_format;
1288
1289        cout << "milliseconds(3) + microseconds(10) = "
1290             <<  boost::chrono::milliseconds(3) + boost::chrono::microseconds(10) << '\n';
1291
1292        cout << "hours(3) + minutes(10) = "
1293             <<  boost::chrono::hours(3) + boost::chrono::minutes(10) << '\n';
1294
1295        cout << "ClockTick(3) + nanoseconds(10) = "
1296             <<  ClockTick(3) + boost::chrono::nanoseconds(10) << '\n';
1297
1298
1299The output could be
1300
1301    Set cout to use short names:
1302    milliseconds(3) + microseconds(10) = 3010 __mus
1303    hours(3) + minutes(10) = 190 m
1304    ClockTick(3) + nanoseconds(10) = 56 [1/5000000000]s
1305
1306    system_clock::now() = 129387415616250000 [1/10000000]s since Jan 1, 1970
1307    monotonic_clock::now() = 37297387636417 ns since boot
1308
1309    Set cout to use long names:
1310    high_resolution_clock::now() = 37297387655134 nanoseconds since boot
1311
1312The [mu] for microsecond is specified to be U+00B5, encoded as UTF-8, UTF-16 or UTF-32 as appropriate for the stream's character size.
1313
1314When the format decision is taken at runtime, it could be better to use the parameterized manipulator __duration_fmt as in
1315
1316  duration_style style;
1317  //...
1318  cout << duration_fmt(style);
1319
1320
1321
1322Parsing a __duration follows rules analogous to the __duration converting constructor. A value and a unit (SI symbol or prefixed) are read from the `basic_istream`. If the __duration has an integral representation, then the value parsed must be exactly representable in the target __duration (after conversion to the target __duration units), else __failbit is set. __durations based on floating-point representations can be parsed using any units that do not cause overflow.
1323
1324For example a stream containing "5000 milliseconds" can be parsed into seconds, but if the stream contains "3001 ms", parsing into `seconds` will cause __failbit to be set.
1325
1326__example
1327
1328    #include <boost/chrono/chrono_io.hpp>
1329    #include <sstream>
1330    #include <cassert>
1331
1332    int main()
1333    {
1334        using namespace std;
1335
1336        istringstream in("5000 milliseconds 4000 ms 3001 ms");
1337        boost::chrono::seconds d(0);
1338        in >> d;
1339        assert(in.good());
1340        assert(d == seconds(5));
1341        in >> d;
1342        assert(in.good());
1343        assert(d == seconds(4));
1344        in >> d;
1345        assert(in.fail());
1346        assert(d == seconds(4));
1347
1348        return 0;
1349    }
1350
1351
1352Note that a __duration failure may occur late in the parsing process. This means that the characters making up the failed parse in the stream are usually consumed despite the failure to successfully parse.
1353
1354Sometimes in templated code it is difficult to know what the unit of your duration is. It is all deterministic, and inspect-able. But it can be inconvenient to do so, especially if you just need to print out a "debugging" statement. For example:
1355
1356    // round to nearest, to even on tie
1357    template <class __To, class Rep, class Period>
1358    To
1359    round(const duration<Rep, Period>& d)
1360    {
1361        To t0 = duration_cast<To>(d);
1362        To t1 = t0;
1363        ++t1;
1364        auto diff0 = d - t0;
1365        cout << "diff0 = " << diff0 << '\n';
1366        auto diff1 = t1 - d;
1367        cout << "diff1 = " << diff1 << '\n';
1368        if (diff0 == diff1)
1369        {
1370            if (t0.count() & 1)
1371                return t1;
1372            return t0;
1373        }
1374        else if (diff0 < diff1)
1375            return t0;
1376        return t1;
1377    }
1378
1379This is where I/O for duration really shines. The compiler knows what the type of diff0 is and with this proposal that type (with proper units) will automatically be printed out for you. For example:
1380
1381    milliseconds ms = round<milliseconds>(nanoseconds(123));  // diff0 = 123 nanoseconds
1382                                                              // diff1 = 999877 nanoseconds
1383    milliseconds ms = round<milliseconds>(Ticks(44));         // diff0 = 2 [1/3000]seconds
1384                                                              // diff1 = 1 [1/3000]second
1385
1386This simple I/O will make duration so much more accessible to programmers.
1387
1388[endsect]
1389
1390[section:system_clock_time_point_io `system_clock::time_point`]
1391
1392[/warning
1393
1394This feature has been disable defining `BOOST_CHRONO_DONT_PROVIDE_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT` until a fix for the following ticket is found:
1395
1396- [@http://svn.boost.org/trac/boost/ticket/7547 #7547] time_point<system_clock> input version 2 fails to compile
1397
1398- [@http://svn.boost.org/trac/boost/ticket/7546 #7546] time_point<system_clock> output version 2 fails to compile
1399
1400In this case the io operators behave like any time_point as defined in next section.
1401
1402In order to enable this features on compilers working with, you will need to define `BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT`.
1403
1404]
1405
1406__system_clock is special. It is the only clock that has conversions between its `time_point` and `time_t`. C subsequently relates time_t to the [@http://en.wikipedia.org/wiki/Gregorian_calendar Gregorian calendar] via `ctime`, `gmtime`, `localtime`, and `strftime`. Neither C, nor POSIX relate `time_t` to any calendar other than the [@http://en.wikipedia.org/wiki/Gregorian_calendar Gregorian calendar]. ISO 8601 is specified only in terms of the [@http://en.wikipedia.org/wiki/Gregorian_calendar Gregorian calendar].
1407
1408__Boost_Chrono provides `system_clock::time_point` I/O in terms of the Gregorian calendar, and no other calendar. However as `system_clock::time_point` remains convertible with `time_t`, it is possible for clients to create other calendars which interoperate with `time_t` and subsequently `system_clock::time_point`.
1409
1410Furthermore, it is existing practice for all major hosted operating systems to store system time in a format which facilitates display as [@http://en.wikipedia.org/wiki/Coordinated_Universal_Time Coordinated Universal Time] (UTC). Therefore __Boost_Chrono provides that the default output for `system_clock::time_point` be in a format that represents a point in time with respect to UTC.
1411
1412    cout << system_clock::now() << '\n';
1413
1414could output
1415
1416    2011-09-15 18:36:59.325132 +0000
1417
1418This format is strongly influenced by ISO 8601, but places a ' ' between the date and time instead of a 'T'. The former appears to more accurately represent existing practice. A fully numeric format was chosen so as to be understandable to as large a group of human readers as possible. A 24 hour format was chosen for the same reasons.
1419
1420Of the referenced standards, only ISO 8601 discusses the output of fractional seconds. Neither C nor POSIX have built-in functionality for this. However it appears to be universal (as of this writing) that `system_clock::period` is sub-second. And it seems desirable that if you stream out a `system_clock::time_point`, you ought to be able to stream it back in and get the same value. Therefore the streaming of fractional seconds (at least by default) appears to be unavoidable.
1421
1422Finally the trailing " +0000" disambiguates the UTC-formatted `system_clock::time_point` from one formatted with respect to the local time zone of the computer. The latter can easily be achieved with:
1423
1424    cout << time_fmt(local) << system_clock::now() << '\n';
1425
1426that could result in
1427
1428    2011-09-15 14:36:59.325132 -0400
1429
1430Note that `system_clock::time_point` itself is neither UTC, nor the local time. However in practice, `system_clock::time_point` is a count of ticks beyond some epoch which is synchronized with UTC. So as a mobile computer moves across time zones, the time zone traversal does not impact the value of a `system_clock::time_point` produced by `system_clock::now()`. And it is only in formatting it for human consumption that one can choose UTC or the local time zone. C and POSIX treat `time_t` just as __Boost_Chrono treats `system_clock::time_point`:
1431
1432    tm* gmtime(const time_t* timer) -> UTC
1433    tm* localtime(const time_t* timer) -> local time
1434
1435This proposal simply extends the C/POSIX `time_t` functionality to C++ syntax and `system_clock::time_point`.
1436
1437The `time_fmt()` manipulator is "sticky". It will remain in effect until the stream destructs or until it is changed. The stream can be reset to its default state with:
1438
1439    cout << time_fmt(utc);
1440
1441And the formatting can be further customized by using the time format sequences. For example:
1442
1443    cout << time_fmt(local, "%A %B %e, %Y %r");
1444    cout << system_clock::now() << '\n';  // Sunday April 24, 2011 02:36:59 PM
1445
1446When specifying formatting manipulators for wide streams, use wide strings.
1447
1448You can use the same manipulators with istreams to specify parsing sequences.
1449
1450Unfortunately there are no formatting/parsing sequences which indicate fractional seconds. __Boost_Chrono does not provide such sequences. In the meantime, one can format and parse fractional seconds for `system_clock::time_point` by defaulting the format, or by using an empty string in `time_fmt()`.
1451
1452The stream's current locale may impact the parsing/format sequences supplied to the `system_clock::time_point` manipulators (e.g. names of days of the week, and names of months).
1453[endsect]
1454
1455[section:other_clocks_time_point_io Other clocks time_point]
1456
1457Unlike `system_clock::time_point`, the other clocks have no conversion with `time_t`. There is likely no relationship between steady_clock::time_point and UTC at all (UTC is not steady).
1458
1459In general a __time_point is formatted by outputting its internal __duration followed by a string that describes the __time_point`::clock` epoch. This string will vary for each distinct clock, and for each implementation of the supplied clocks.
1460
1461    #ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
1462        cout << "steady_clock::now() = " << boost::chrono::steady_clock::now() << '\n';
1463    #endif
1464        cout << "\nSet cout to use long names:\n"
1465                << boost::chrono::duration_long
1466                << "high_resolution_clock::now() = "
1467                << boost::chrono::high_resolution_clock::now() << '\n';
1468
1469The output could be
1470
1471    steady_clock::now() = 37297387636417 ns since boot
1472
1473    Set cout to use long names:
1474    high_resolution_clock::now() = 37297387655134 nanoseconds since boot
1475
1476
1477[/
1478There ...
1479        cout << "\nsystem_clock::now() = " << boost::chrono::system_clock::now() << '\n';
1480
1481The output could be
1482    system_clock::now() = 129387415616250000 [1/10000000]s since Jan 1, 1970
1483
1484]
1485
1486Parsing a __time_point involves first parsing a __duration and then parsing the epoch string. If the epoch string does not match that associated with `time_point::clock` then failbit will be set.
1487
1488__example
1489
1490    #include <boost/chrono/chrono_io.hpp>
1491    #include <sstream>
1492    #include <iostream>
1493    #include <cassert>
1494
1495    int main()
1496    {
1497        using namespace std;
1498
1499        boost::chrono::high_resolution_clock::time_point t0 = boost::chrono::high_resolution_clock::now();
1500        stringstream io;
1501        io << t0;
1502        boost::chrono::high_resolution_clock::time_point t1;
1503        io >> t1;
1504        assert(!io.fail());
1505        cout << io.str() << '\n';
1506        cout << t0 << '\n';
1507        cout << t1 << '\n';
1508        boost::chrono::high_resolution_clock::time_point t = boost::chrono::high_resolution_clock::now();
1509        cout << t << '\n';
1510
1511        cout << "That took " << t - t0 << '\n';
1512        cout << "That took " << t - t1 << '\n';
1513
1514        return 0;
1515    }
1516
1517The output could be:
1518
1519    50908679121461 nanoseconds since boot
1520    That took 649630 nanoseconds
1521
1522Here's a simple example to find out how many hours the computer has been up (on this platform):
1523
1524    #include <boost/chrono/chrono_io.hpp>
1525    #include <iostream>
1526
1527    int main()
1528    {
1529        using namespace std;
1530        using namespace boost;
1531
1532        typedef boost::chrono::time_point<boost::chrono::steady_clock, boost::chrono::duration<double, boost::ratio<3600> > > T;
1533        T tp = boost::chrono::steady_clock::now();
1534        std::cout << tp << '\n';
1535        return 0;
1536    }
1537
1538The output could be:
1539
1540    17.8666 hours since boot
1541
1542[endsect]
1543
1544[section Low level I/O]
1545[/====================]
1546
1547The I/O interface described in the preceding I/O sections were at the user level. These services are based on low level services that are useful when writing libraries. The low level services are related to access to the associated ios state and locale facets. The design follows the C++ IOStreams standard design:
1548
1549The library encapsulate the locale-dependent parsing and formatting of __duration into a new facet class. Let's focus on formatting in this example. The concerned facet class is  __duration_put, analogous to time_put, money_put, etc.
1550
1551The use of this facet is similar to the time_put facet.
1552
1553[endsect] [/ Low level I/O]
1554
1555[endsect] [/ I/O]
1556
1557[endsect]
1558[/===============]
1559[section Examples]
1560[/===============]
1561
1562
1563
1564[section Duration]
1565
1566[/===============]
1567[section How you Override the Duration's Default Constructor]
1568
1569Next we show how to override the __duration_s default constructor to do anything you want (in this case set it to zero). All we need to do is to change the representation
1570
1571    namespace I_dont_like_the_default_duration_behavior {
1572
1573    template <class R>
1574    class zero_default
1575    {
1576    public:
1577        typedef R rep;
1578
1579    private:
1580        rep rep_;
1581    public:
1582        zero_default(rep i = 0) : rep_(i) {}
1583        operator rep() const {return rep_;}
1584
1585        zero_default& operator+=(zero_default x) {rep_ += x.rep_; return *this;}
1586        zero_default& operator-=(zero_default x) {rep_ -= x.rep_; return *this;}
1587        zero_default& operator*=(zero_default x) {rep_ *= x.rep_; return *this;}
1588        zero_default& operator/=(zero_default x) {rep_ /= x.rep_; return *this;}
1589
1590        zero_default  operator+ () const {return *this;}
1591        zero_default  operator- () const {return zero_default(-rep_);}
1592        zero_default& operator++()       {++rep_; return *this;}
1593        zero_default  operator++(int)    {return zero_default(rep_++);}
1594        zero_default& operator--()       {--rep_; return *this;}
1595        zero_default  operator--(int)    {return zero_default(rep_--);}
1596
1597        friend zero_default operator+(zero_default x, zero_default y) {return x += y;}
1598        friend zero_default operator-(zero_default x, zero_default y) {return x -= y;}
1599        friend zero_default operator*(zero_default x, zero_default y) {return x *= y;}
1600        friend zero_default operator/(zero_default x, zero_default y) {return x /= y;}
1601
1602        friend bool operator==(zero_default x, zero_default y) {return x.rep_ == y.rep_;}
1603        friend bool operator!=(zero_default x, zero_default y) {return !(x == y);}
1604        friend bool operator< (zero_default x, zero_default y) {return x.rep_ < y.rep_;}
1605        friend bool operator<=(zero_default x, zero_default y) {return !(y < x);}
1606        friend bool operator> (zero_default x, zero_default y) {return y < x;}
1607        friend bool operator>=(zero_default x, zero_default y) {return !(x < y);}
1608    };
1609
1610    typedef boost::chrono::__duration<zero_default<long long>, boost::nano        > nanoseconds;
1611    typedef boost::chrono::__duration<zero_default<long long>, boost::micro       > microseconds;
1612    typedef boost::chrono::__duration<zero_default<long long>, boost::milli       > milliseconds;
1613    typedef boost::chrono::__duration<zero_default<long long>                      > seconds;
1614    typedef boost::chrono::__duration<zero_default<long long>, boost::ratio<60>   > minutes;
1615    typedef boost::chrono::__duration<zero_default<long long>, boost::ratio<3600> > hours;
1616    }
1617
1618Usage
1619
1620    using namespace I_dont_like_the_default_duration_behavior;
1621
1622    milliseconds ms;
1623    std::cout << ms.count() << '\n';
1624
1625['See the source file [@boost:libs/chrono/example/i_dont_like_the_default_duration_behavior.cpp example/i_dont_like_the_default_duration_behavior.cpp]]
1626
1627[endsect]
1628[/
1629[/=========================]
1630[section runtime_resolution]
1631
1632This example shows how to handle duration with resolution not known until run-time
1633
1634    class duration
1635    {
1636    public:
1637        typedef long long rep;
1638    private:
1639        rep rep_;
1640
1641        static const double ticks_per_nanosecond;
1642
1643    public:
1644        typedef boost::chrono::duration<double, boost::nano> tonanosec;
1645
1646        duration() {} // = default;
1647        explicit duration(const rep& r) : rep_(r) {}
1648
1649        // conversions
1650        explicit duration(const tonanosec& d)
1651                : rep_(static_cast<rep>(d.count() * ticks_per_nanosecond)) {}
1652
1653        // explicit
1654           operator tonanosec() const {return tonanosec(rep_/ticks_per_nanosecond);}
1655
1656        // observer
1657
1658        rep count() const {return rep_;}
1659
1660        // arithmetic
1661
1662        duration& operator+=(const duration& d) {rep_ += d.rep_; return *this;}
1663        duration& operator-=(const duration& d) {rep_ += d.rep_; return *this;}
1664        duration& operator*=(rep rhs)           {rep_ *= rhs; return *this;}
1665        duration& operator/=(rep rhs)           {rep_ /= rhs; return *this;}
1666
1667        duration  operator+() const {return *this;}
1668        duration  operator-() const {return duration(-rep_);}
1669        duration& operator++()      {++rep_; return *this;}
1670        duration  operator++(int)   {return duration(rep_++);}
1671        duration& operator--()      {--rep_; return *this;}
1672        duration  operator--(int)   {return duration(rep_--);}
1673
1674        friend duration operator+(duration x, duration y) {return x += y;}
1675        friend duration operator-(duration x, duration y) {return x -= y;}
1676        friend duration operator*(duration x, rep y)      {return x *= y;}
1677        friend duration operator*(rep x, duration y)      {return y *= x;}
1678        friend duration operator/(duration x, rep y)      {return x /= y;}
1679
1680        friend bool operator==(duration x, duration y) {return x.rep_ == y.rep_;}
1681        friend bool operator!=(duration x, duration y) {return !(x == y);}
1682        friend bool operator< (duration x, duration y) {return x.rep_ < y.rep_;}
1683        friend bool operator<=(duration x, duration y) {return !(y < x);}
1684        friend bool operator> (duration x, duration y) {return y < x;}
1685        friend bool operator>=(duration x, duration y) {return !(x < y);}
1686    };
1687
1688['See the source file [@boost:libs/chrono/example/runtime_resolution.cpp here]]
1689
1690[endsect]
1691]
1692[/================]
1693[section Saturating]
1694
1695A "saturating" signed integral type is developed.  This type has +/- infinity and a NaN (like IEEE floating-point) but otherwise obeys signed integral arithmetic. This class is subsequently used as the template parameter Rep in boost::chrono::__duration to demonstrate a duration class that does not silently ignore overflow.
1696
1697['See the source file [@boost:libs/chrono/example/saturating.cpp example/saturating.cpp]]
1698
1699[endsect]
1700
1701
1702
1703[/==================]
1704[section xtime Conversions]
1705
1706Example round_up utility:  converts d to To, rounding up for inexact conversions
1707Being able to *easily* write this function is a major feature!
1708
1709    #include <boost/chrono.hpp>
1710    #include <boost/type_traits.hpp>
1711
1712    #include <iostream>
1713
1714    template <class To, class Rep, class Period>
1715    To
1716    round_up(boost::chrono::duration<Rep, Period> d)
1717    {
1718        To result = boost::chrono::duration_cast<To>(d);
1719        if (result < d)
1720            ++result;
1721        return result;
1722    }
1723
1724To demonstrate interaction with an xtime-like facility:
1725
1726
1727    struct xtime
1728    {
1729        long sec;
1730        unsigned long usec;
1731    };
1732
1733    template <class Rep, class Period>
1734    xtime
1735    to_xtime_truncate(boost::chrono::__duration<Rep, Period> d)
1736    {
1737        xtime xt;
1738        xt.sec = static_cast<long>(boost::chrono::__duration_cast<__seconds>(d).count());
1739        xt.usec = static_cast<long>(boost::chrono::__duration_cast<__microseconds>(d - __seconds(xt.sec)).count());
1740        return xt;
1741    }
1742
1743    template <class Rep, class Period>
1744    xtime
1745    to_xtime_round_up(boost::chrono::__duration<Rep, Period> d)
1746    {
1747        xtime xt;
1748        xt.sec = static_cast<long>(boost::chrono::__duration_cast<__seconds>(d).count());
1749        xt.usec = static_cast<unsigned long>(round_up<boost::chrono::__microseconds>(d - boost::chrono::__seconds(xt.sec)).count());
1750        return xt;
1751    }
1752
1753    microseconds
1754    from_xtime(xtime xt)
1755    {
1756        return boost::chrono::__seconds(xt.sec) + boost::chrono::__microseconds(xt.usec);
1757    }
1758
1759    void print(xtime xt)
1760    {
1761        std::cout << '{' << xt.sec << ',' << xt.usec << "}\n";
1762    }
1763
1764Usage
1765
1766        xtime xt = to_xtime_truncate(seconds(3) + boost::chrono::__milliseconds(251));
1767        print(xt);
1768        boost::chrono::milliseconds ms = boost::chrono::__duration_cast<boost::chrono::__milliseconds>(from_xtime(xt));
1769        std::cout << ms.count() << " milliseconds\n";
1770        xt = to_xtime_round_up(ms);
1771        print(xt);
1772        xt = to_xtime_truncate(boost::chrono::seconds(3) + __nanoseconds(999));
1773        print(xt);
1774        xt = to_xtime_round_up(boost::chrono::seconds(3) + __nanoseconds(999));
1775        print(xt);
1776
1777
1778['See the source file [@boost:libs/chrono/example/xtime.cpp xtime.cpp]]
1779
1780[endsect]
1781
1782
1783[endsect]
1784[section Clocks]
1785
1786[/==================]
1787[section Cycle count]
1788
1789Users can easily create their own clocks, with both points in time and time durations which have a representation and precision of their own choosing. For example if there is a hardware counter which simply increments a count with each cycle of the cpu, one can very easily build clocks, time points and durations on top of that, using only a few tens of lines of code. Such systems can be used to call the time-sensitive threading API's such as sleep, wait on a condition variable, or wait for a mutex lock. The API proposed herein is not sensitive as to whether this is a 300MHz clock (with a 3 1/3 nanosecond tick period) or a 3GHz clock (with a tick period of  1/3 of a nanosecond). And the resulting code will be just as efficient as if the user wrote a special purpose clock cycle counter.
1790
1791
1792    #include <boost/chrono.hpp>
1793    #include <boost/type_traits.hpp>
1794    #include <iostream>
1795
1796    template <long long speed>
1797    struct cycle_count
1798    {
1799        typedef typename boost::__ratio_multiply__<boost::__ratio<speed>, boost::__mega>::type
1800            frequency;  // Mhz
1801        typedef typename boost::__ratio_divide__<boost::__ratio<1>, frequency>::type period;
1802        typedef long long rep;
1803        typedef boost::chrono::__duration<rep, period> duration;
1804        typedef boost::chrono::__time_point<cycle_count> time_point;
1805
1806        static time_point now()
1807        {
1808            static long long tick = 0;
1809            // return exact cycle count
1810            return time_point(duration(++tick));  // fake access to clock cycle count
1811        }
1812    };
1813
1814    template <long long speed>
1815    struct approx_cycle_count
1816    {
1817        static const long long frequency = speed * 1000000;  // MHz
1818        typedef nanoseconds duration;
1819        typedef duration::rep rep;
1820        typedef duration::period period;
1821        static const long long nanosec_per_sec = period::den;
1822        typedef boost::chrono::__time_point<approx_cycle_count> time_point;
1823
1824        static time_point now()
1825        {
1826            static long long tick = 0;
1827            // return cycle count as an approximate number of nanoseconds
1828            // compute as if nanoseconds is only duration in the std::lib
1829            return time_point(duration(++tick * nanosec_per_sec / frequency));
1830        }
1831    };
1832
1833['See the source file [@boost:libs/chrono/example/cycle_count.cpp cycle_count.cpp]]
1834
1835[endsect]
1836
1837[/==================]
1838[section xtime_clock]
1839
1840This example demonstrates the use of a timeval-like struct to be used as the representation type for both __duration and __time_point.
1841
1842    class xtime {
1843    private:
1844        long tv_sec;
1845        long tv_usec;
1846
1847        void fixup() {
1848            if (tv_usec < 0) {
1849                tv_usec += 1000000;
1850                --tv_sec;
1851            }
1852        }
1853
1854    public:
1855        explicit xtime(long sec, long usec) {
1856            tv_sec = sec;
1857            tv_usec = usec;
1858            if (tv_usec < 0 || tv_usec >= 1000000) {
1859                tv_sec += tv_usec / 1000000;
1860                tv_usec %= 1000000;
1861                fixup();
1862            }
1863        }
1864
1865        explicit xtime(long long usec) {
1866            tv_usec = static_cast<long>(usec % 1000000);
1867            tv_sec  = static_cast<long>(usec / 1000000);
1868            fixup();
1869        }
1870
1871        // explicit
1872        operator long long() const {return static_cast<long long>(tv_sec) * 1000000 + tv_usec;}
1873
1874        xtime& operator += (xtime rhs) {
1875            tv_sec += rhs.tv_sec;
1876            tv_usec += rhs.tv_usec;
1877            if (tv_usec >= 1000000) {
1878                tv_usec -= 1000000;
1879                ++tv_sec;
1880            }
1881            return *this;
1882        }
1883
1884        xtime& operator -= (xtime rhs) {
1885            tv_sec -= rhs.tv_sec;
1886            tv_usec -= rhs.tv_usec;
1887            fixup();
1888            return *this;
1889        }
1890
1891        xtime& operator %= (xtime rhs) {
1892            long long t = tv_sec * 1000000 + tv_usec;
1893            long long r = rhs.tv_sec * 1000000 + rhs.tv_usec;
1894            t %= r;
1895            tv_sec = static_cast<long>(t / 1000000);
1896            tv_usec = static_cast<long>(t % 1000000);
1897            fixup();
1898            return *this;
1899        }
1900
1901        friend xtime operator+(xtime x, xtime y) {return x += y;}
1902        friend xtime operator-(xtime x, xtime y) {return x -= y;}
1903        friend xtime operator%(xtime x, xtime y) {return x %= y;}
1904
1905        friend bool operator==(xtime x, xtime y)
1906            { return (x.tv_sec == y.tv_sec && x.tv_usec == y.tv_usec); }
1907
1908        friend bool operator<(xtime x, xtime y) {
1909            if (x.tv_sec == y.tv_sec)
1910                return (x.tv_usec < y.tv_usec);
1911            return (x.tv_sec < y.tv_sec);
1912        }
1913
1914        friend bool operator!=(xtime x, xtime y) { return !(x == y); }
1915        friend bool operator> (xtime x, xtime y) { return y < x; }
1916        friend bool operator<=(xtime x, xtime y) { return !(y < x); }
1917        friend bool operator>=(xtime x, xtime y) { return !(x < y); }
1918
1919        friend std::ostream& operator<<(std::ostream& os, xtime x)
1920            {return os << '{' << x.tv_sec << ',' << x.tv_usec << '}';}
1921    };
1922
1923Clock based on timeval-like struct.
1924
1925    class xtime_clock
1926    {
1927    public:
1928        typedef xtime                                  rep;
1929        typedef boost::micro                           period;
1930        typedef boost::chrono::duration<rep, period>   duration;
1931        typedef boost::chrono::time_point<xtime_clock> time_point;
1932
1933        static time_point now()
1934        {
1935        #if defined(BOOST_CHRONO_WINDOWS_API)
1936            time_point t(duration(xtime(0)));
1937            gettimeofday((timeval*)&t, 0);
1938            return t;
1939
1940        #elif defined(BOOST_CHRONO_MAC_API)
1941
1942            time_point t(duration(xtime(0)));
1943            gettimeofday((timeval*)&t, 0);
1944            return t;
1945
1946        #elif defined(BOOST_CHRONO_POSIX_API)
1947            //time_point t(0,0);
1948
1949            timespec ts;
1950            ::clock_gettime( CLOCK_REALTIME, &ts );
1951
1952            xtime xt( ts.tv_sec, ts.tv_nsec/1000);
1953            return time_point(duration(xt));
1954
1955        #endif  // POSIX
1956        }
1957    };
1958
1959Usage of xtime_clock
1960
1961        std::cout << "sizeof xtime_clock::time_point = " << sizeof(xtime_clock::time_point) << '\n';
1962        std::cout << "sizeof xtime_clock::duration = " << sizeof(xtime_clock::duration) << '\n';
1963        std::cout << "sizeof xtime_clock::rep = " << sizeof(xtime_clock::rep) << '\n';
1964        xtime_clock::duration delay(boost::chrono::milliseconds(5));
1965        xtime_clock::time_point start = xtime_clock::now();
1966        while (xtime_clock::now() - start <= delay) {}
1967        xtime_clock::time_point stop = xtime_clock::now();
1968        xtime_clock::duration elapsed = stop - start;
1969        std::cout << "paused " << boost::chrono::::nanoseconds(elapsed).count() << " nanoseconds\n";
1970
1971
1972['See the source file [@boost:libs/chrono/example/timeval_demo.cpp example/timeval_demo.cpp]]
1973
1974[endsect]
1975[endsect]
1976
1977
1978
1979[/
1980[/======================================================]
1981[section Howard Hinnant's original demonstration program]
1982
1983['See the source file [@boost:libs/chrono/example/time2_demo.cpp example/time2_demo.cpp]]
1984
1985[endsect]
1986]
1987[section Time Point]
1988
1989[/==================]
1990[section min Utility]
1991
1992The user can define a function returning the earliest __time_point as follows:
1993
1994    template <class __Clock, class __Duration1, class __Duration2>
1995    typename boost::__common_type<__time_point<__Clock, __Duration1>,
1996                         __time_point<__Clock, __Duration2> >::type
1997    min(__time_point<__Clock, __Duration1> t1, __time_point<__Clock, __Duration2> t2)
1998    {
1999        return t2 < t1 ? t2 : t1;
2000    }
2001
2002Being able to *easily* write this function is a major feature!
2003
2004    BOOST_AUTO(t1, system_clock::now() + seconds(3));
2005    BOOST_AUTO(t2, system_clock::now() + nanoseconds(3));
2006    BOOST_AUTO(t3, min(t1, t2));
2007
2008['See the source file [@boost:libs/chrono/example/min_time_point.cpp example/min_time_point.cpp]]
2009
2010[endsect]
2011
2012
2013[/===============================================================]
2014[section A Tiny Program that Times How Long Until a Key is Struck]
2015
2016    #include <boost/chrono.hpp>
2017    #include <iostream>
2018    #include <iomanip>
2019
2020    using namespace boost::chrono;
2021
2022    template< class __Clock >
2023    class timer
2024    {
2025      typename __Clock::time_point start;
2026    public:
2027      timer() : start( __Clock::now() ) {}
2028      typename __Clock::duration elapsed() const
2029      {
2030        return __Clock::now() - start;
2031      }
2032      double seconds() const
2033      {
2034        return elapsed().count() * ((double)Clock::period::num/Clock::period::den);
2035      }
2036    };
2037
2038    int main()
2039    {
2040      timer<__system_clock> t1;
2041      timer<__steady_clock> t2;
2042      timer<__high_resolution_clock> t3;
2043
2044      std::cout << "Type the Enter key: ";
2045      std::cin.get();
2046
2047      std::cout << std::fixed << std::setprecision(9);
2048      std::cout << "system_clock-----------: "
2049                << t1.seconds() << " seconds\n";
2050      std::cout << "steady_clock--------: "
2051                << t2.seconds() << " seconds\n";
2052      std::cout << "high_resolution_clock--: "
2053                << t3.seconds() << " seconds\n";
2054
2055      __system_clock::time_point d4 = __system_clock::now();
2056      __system_clock::time_point d5 = __system_clock::now();
2057
2058      std::cout << "\nsystem_clock latency-----------: " << (d5 - d4).count() << std::endl;
2059
2060      __steady_clock::time_point d6 = __steady_clock::now();
2061      __steady_clock::time_point d7 = __steady_clock::now();
2062
2063      std::cout << "steady_clock latency--------: " << (d7 - d6).count() << std::endl;
2064
2065      __high_resolution_clock::time_point d8 = __high_resolution_clock::now();
2066      __high_resolution_clock::time_point d9 = __high_resolution_clock::now();
2067
2068      std::cout << "high_resolution_clock latency--: " << (d9 - d8).count() << std::endl;
2069
2070      std::time_t now = __system_clock::to_time_t(__system_clock::now());
2071
2072      std::cout << "\nsystem_clock::now() reports UTC is "
2073        << std::asctime(std::gmtime(&now)) << "\n";
2074
2075      return 0;
2076    }
2077
2078The output of this program run looks like this:
2079
2080
2081
2082
2083['See the source file [@boost:libs/chrono/example/await_keystroke.cpp example/await_keystroke.cpp]]
2084
2085[endsect]
2086
2087[/
2088[/===============================================================]
2089[section Time Command]
2090
2091    #include <boost/chrono/stopclock.hpp>
2092    #include <cstdlib>
2093    #include <string>
2094    #include <iostream>
2095
2096    int main( int argc, char * argv[] )
2097    {
2098      if ( argc == 1 )
2099      {
2100        std::cout << "invoke: timex [-v] command [args...]\n"
2101          "  command will be executed and timings displayed\n"
2102          "  -v option causes command and args to be displayed\n";
2103        return 1;
2104      }
2105
2106      std::string s;
2107
2108      bool verbose = false;
2109      if ( argc > 1 && *argv[1] == '-' && *(argv[1]+1) == 'v' )
2110      {
2111        verbose = true;
2112        ++argv;
2113        --argc;
2114      }
2115
2116      for ( int i = 1; i < argc; ++i )
2117      {
2118        if ( i > 1 ) s += ' ';
2119        s += argv[i];
2120      }
2121
2122      if ( verbose )
2123        { std::cout << "command: \"" << s.c_str() << "\"\n"; }
2124
2125      boost::chrono::__stopclock<> t;
2126
2127      return std::system( s.c_str() );
2128    }
2129
2130['See the source file [@boost:libs/chrono/example/timex.cpp example/timex.cpp]]
2131
2132[endsect]
2133]
2134
2135[section 24 Hours Display]
2136
2137In the example above we take advantage of the fact that __time_points convert as long as they have the same clock, and as long as their internal __durations convert. We also take advantage of the fact that a __duration with a floating-point representation will convert from anything. Finally the I/O system discovers the more readable "hours" unit for our `duration<double, ratio<3600>>`.
2138
2139There are many other ways to format __durations and __time_points. For example see [@http://en.wikipedia.org/wiki/ISO_8601#Durations ISO 8601]. Instead of coding every possibility into `operator<<`, which would lead to significant code bloat for even the most trivial uses, this document seeks to inform the reader how to write custom I/O when desired.
2140
2141As an example, the function below streams arbitrary __durations to arbitrary `basic_ostreams` using the format:
2142
2143    [-]d/hh:mm:ss.cc
2144
2145Where:
2146
2147* `d` is the number of `days`
2148* `h` is the number of `hours`
2149* `m` is the number of `minutes`
2150* `ss.cc` is the number of `seconds` rounded to the nearest hundredth of a second
2151
2152    #include <boost/chrono/chrono_io.hpp>
2153    #include <ostream>
2154    #include <iostream>
2155
2156    // format duration as [-]d/hh::mm::ss.cc
2157    template <class CharT, class Traits, class Rep, class Period>
2158    std::basic_ostream<CharT, Traits>&
2159    display(std::basic_ostream<CharT, Traits>& os,
2160            boost::chrono::duration<Rep, Period> d)
2161    {
2162        using namespace std;
2163        using namespace boost;
2164
2165        typedef boost::chrono::duration<long long, boost::ratio<86400> > days;
2166        typedef boost::chrono::duration<long long, boost:centi> centiseconds;
2167
2168        // if negative, print negative sign and negate
2169        if (d < boost::chrono::duration<Rep, Period>(0))
2170        {
2171            d = -d;
2172            os << '-';
2173        }
2174        // round d to nearest centiseconds, to even on tie
2175        centiseconds cs = boost::chrono::duration_cast<centiseconds>(d);
2176        if (d - cs > boost::chrono::milliseconds(5)
2177            || (d - cs == boost::chrono::milliseconds(5) && cs.count() & 1))
2178            ++cs;
2179        // separate seconds from centiseconds
2180        boost::chrono::seconds s = boost::chrono::duration_cast<boost::chrono::seconds>(cs);
2181        cs -= s;
2182        // separate minutes from seconds
2183        boost::chrono::minutes m = boost::chrono::duration_cast<boost::chrono::minutes>(s);
2184        s -= m;
2185        // separate hours from minutes
2186        boost::chrono::hours h = boost::chrono::duration_cast<boost::chrono::hours>(m);
2187        m -= h;
2188        // separate days from hours
2189        days dy = boost::chrono::duration_cast<days>(h);
2190        h -= dy;
2191        // print d/hh:mm:ss.cc
2192        os << dy.count() << '/';
2193        if (h < boost::chrono::hours(10))
2194            os << '0';
2195        os << h.count() << ':';
2196        if (m < boost::chrono::minutes(10))
2197            os << '0';
2198        os << m.count() << ':';
2199        if (s < boost::chrono::seconds(10))
2200            os << '0';
2201        os << s.count() << '.';
2202        if (cs < boost::chrono::centiseconds(10))
2203            os << '0';
2204        os << cs.count();
2205        return os;
2206    }
2207
2208    int main()
2209    {
2210        using namespace std;
2211        using namespace boost;
2212
2213        display(cout, boost::chrono::steady_clock::now().time_since_epoch()
2214                      + boost::chrono::duration<long, boost::mega>(1)) << '\n';
2215        display(cout, -boost::chrono::milliseconds(6)) << '\n';
2216        display(cout, boost::chrono::duration<long, boost::mega>(1)) << '\n';
2217        display(cout, -boost::chrono::duration<long, boost::mega>(1)) << '\n';
2218    }
2219
2220The output could be:
2221
2222    12/06:03:22.95
2223    -0/00:00:00.01
2224    11/13:46:40.00
2225    -11/13:46:40.00
2226
2227[endsect]
2228
2229
2230[/=======================================================]
2231[section Simulated Thread Interface Demonstration Program]
2232
2233The C++11 standard library's multi-threading library requires the ability to deal with the representation of time in a manner consistent with modern C++ practices. Next is a simulation of this interface.
2234
2235The non-member sleep functions can be emulated as follows:
2236
2237    namespace boost { namespace this_thread {
2238
2239    template <class Rep, class Period>
2240    void sleep_for(const chrono::__duration<Rep, Period>& d) {
2241        chrono::__microseconds t = chrono::__duration_cast<chrono::__microseconds>(d);
2242        if (t < d)
2243            ++t;
2244        if (t > chrono::__microseconds(0))
2245            std::cout << "sleep_for " << t.count() << " microseconds\n";
2246    }
2247
2248    template <class __Clock, class __Duration>
2249    void sleep_until(const chrono::__time_point<__Clock, __Duration>& t) {
2250        using namespace chrono;
2251        typedef __time_point<__Clock, __Duration> Time;
2252        typedef __system_clock::time_point SysTime;
2253        if (t > __Clock::now()) {
2254            typedef typename __common_type<typename Time::duration,
2255                                         typename SysTime::duration>::type D;
2256            /* auto */ D d = t - __Clock::now();
2257            microseconds us = __duration_cast<__microseconds>(d);
2258            if (us < d)
2259                ++us;
2260            SysTime st = __system_clock::now() + us;
2261            std::cout << "sleep_until    ";
2262            detail::print_time(st);
2263            std::cout << " which is " << (st - __system_clock::now()).count() << " microseconds away\n";
2264        }
2265    }
2266
2267    }}
2268
2269
2270Next is the `boost::thread::timed_mutex` modified functions
2271
2272    namespace boost {
2273    struct timed_mutex {
2274        // ...
2275
2276        template <class Rep, class Period>
2277        bool try_lock_for(const chrono::__duration<Rep, Period>& d) {
2278            chrono::__microseconds t = chrono::__duration_cast<chrono::__microseconds>(d);
2279            if (t <= chrono::__microseconds(0))
2280                return try_lock();
2281            std::cout << "try_lock_for " << t.count() << " microseconds\n";
2282            return true;
2283        }
2284
2285        template <class __Clock, class __Duration>
2286        bool try_lock_until(const chrono::__time_point<__Clock, __Duration>& t)
2287        {
2288            using namespace chrono;
2289            typedef __time_point<__Clock, __Duration> Time;
2290            typedef __system_clock::time_point SysTime;
2291            if (t <= __Clock::now())
2292                return try_lock();
2293            typedef typename __common_type<typename Time::duration,
2294              typename __Clock::duration>::type D;
2295            /* auto */ D d = t - __Clock::now();
2296            microseconds us = __duration_cast<__microseconds>(d);
2297            SysTime st = __system_clock::now() + us;
2298            std::cout << "try_lock_until ";
2299            detail::print_time(st);
2300            std::cout << " which is " << (st - __system_clock::now()).count()
2301              << " microseconds away\n";
2302            return true;
2303        }
2304    };
2305    }
2306
2307`boost::thread::condition_variable` time related function are modified as follows:
2308
2309    namespace boost {
2310    struct condition_variable
2311    {
2312        // ...
2313
2314        template <class Rep, class Period>
2315        bool wait_for(mutex&, const chrono::__duration<Rep, Period>& d) {
2316            chrono::microseconds t = chrono::__duration_cast<chrono::microseconds>(d);
2317            std::cout << "wait_for " << t.count() << " microseconds\n";
2318            return true;
2319        }
2320
2321        template <class __Clock, class __Duration>
2322        bool wait_until(mutex&, const chrono::__time_point<__Clock, __Duration>& t) {
2323            using namespace boost::chrono;
2324            typedef __time_point<__Clock, __Duration> Time;
2325            typedef __system_clock::time_point SysTime;
2326            if (t <= __Clock::now())
2327                return false;
2328            typedef typename __common_type<typename Time::duration,
2329              typename __Clock::duration>::type D;
2330            /* auto */ D d = t - __Clock::now();
2331            microseconds us = __duration_cast<__microseconds>(d);
2332            SysTime st = __system_clock::now() + us;
2333             std::cout << "wait_until     ";
2334            detail::print_time(st);
2335            std::cout << " which is " << (st - __system_clock::now()).count()
2336              << " microseconds away\n";
2337            return true;
2338        }
2339    };
2340    }
2341
2342Next follows how simple is the usage of this functions:
2343
2344    boost::mutex m;
2345    boost::timed_mutex mut;
2346    boost::condition_variable cv;
2347
2348    using namespace boost;
2349
2350    this_thread::sleep_for(chrono::__seconds(3));
2351    this_thread::sleep_for(chrono::__nanoseconds(300));
2352    chrono::__system_clock::time_point time_limit = chrono::__system_clock::now() + chrono::__seconds_(4) + chrono::__milliseconds(500);
2353    this_thread::sleep_until(time_limit);
2354
2355    mut.try_lock_for(chrono::__milliseconds(30));
2356    mut.try_lock_until(time_limit);
2357
2358    cv.wait_for(m, chrono::__minutes(1));    // real code would put this in a loop
2359    cv.wait_until(m, time_limit);  // real code would put this in a loop
2360
2361    // For those who prefer floating-point
2362    this_thread::sleep_for(chrono::__duration<double>(0.25));
2363    this_thread::sleep_until(chrono::__system_clock::now() + chrono::__duration<double>(1.5));
2364
2365
2366['See the source file [@boost:libs/chrono/example/simulated_thread_interface_demo.cpp example/simulated_thread_interface_demo.cpp]]
2367
2368[endsect]
2369
2370[endsect]
2371[section IO]
2372[/=======================================================]
2373[section:french French Output]
2374
2375Example use of output in French
2376
2377    #include <boost/chrono/chrono_io.hpp>
2378    #include <iostream>
2379    #include <locale>
2380
2381    int main()
2382    {
2383        using namespace std;
2384        using namespace boost;
2385        using namespace boost::chrono;
2386
2387        cout.imbue(locale(locale(), new duration_punct<char>
2388            (
2389                duration_punct<char>::use_long,
2390                "secondes", "minutes", "heures",
2391                "s", "m", "h"
2392            )));
2393        hours h(5);
2394        minutes m(45);
2395        seconds s(15);
2396        milliseconds ms(763);
2397        cout << h << ", " << m << ", " << s << " et " << ms << '\n';
2398    }
2399
2400Output is:
2401
2402    5 heures, 45 minutes, 15 secondes et 763 millisecondes
2403
2404['See the source file [@boost:libs/chrono/example/french.cpp example/french.cpp]]
2405
2406[endsect] [/section:french French Output]
2407[endsect] [/section IO]
2408
2409[endsect] [/section Examples]
2410
2411
2412[/================================]
2413[section:ext_references External Resources]
2414[/================================]
2415
2416[variablelist
2417
2418[
2419    [[@http://www.open-std.org/jtc1/sc22/wg21 [*C++ Standards Committee's current Working Paper]]]
2420    [The most authoritative reference material for the library is the C++ Standards Committee's current Working Paper (WP).  20.11 Time utilities "time"]
2421]
2422
2423[
2424    [[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm [*N2661 - A Foundation to Sleep On]]]
2425    [From Howard E. Hinnant, Walter E. Brown, Jeff Garland  and Marc Paterno. Is very informative and provides motivation for key design decisions]
2426]
2427
2428
2429[
2430    [[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3134.html#934 [*LGW 934. duration is missing operator%]]]
2431    [From Terry Golubiewski. Is very informative and provides motivation for key design decisions]
2432]
2433
2434[
2435    [[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3135.html#935 [*LGW 935. clock error handling needs to be specified]]]
2436    [From Beman Dawes. This issue has been stated as NAD Future.]
2437]
2438
2439]
2440
2441[endsect]
2442
2443[endsect]
2444
2445[/=================]
2446[section:reference Reference ]
2447[/=================]
2448
2449As `constexpr` will not be supported by some compilers, it is replaced in the code by `BOOST_CONSTEXPR` for `constexpr` functions and `BOOST_STATIC_CONSTEXPR` for struct/class static fields. The same applies to `noexecpt` which is replaced by `noexcept` in the code.
2450
2451The documentation doesn't use these macros.
2452
2453[/=============================================]
2454[section:chrono_include_hpp Header `<boost/chrono/include.hpp>`]
2455[/=============================================]
2456
2457Include all the chrono header files.
2458
2459    #include <boost/chrono/chrono.hpp>
2460    #include <boost/chrono/chrono_io.hpp>
2461    #include <boost/chrono/process_cpu_clocks.hpp>
2462    #include <boost/chrono/thread_clocks.hpp>
2463    #include <boost/chrono/ceil.hpp>
2464    #include <boost/chrono/floor.hpp>
2465    #include <boost/chrono/round.hpp>
2466
2467[endsect]
2468
2469[section:cpp0x Included on the C++11 Recommendation]
2470
2471[/=============================================]
2472[section:chrono_hpp Header `<boost/chrono.hpp>`]
2473[/=============================================]
2474
2475Include only the standard files.
2476
2477    #include <boost/chrono/chrono.hpp>
2478
2479[endsect]
2480
2481[/=============================================]
2482[section:chrono_chrono_hpp Header `<boost/chrono/chrono.hpp>`]
2483[/=============================================]
2484
2485Include only the standard files.
2486
2487    #include <boost/chrono/duration.hpp>
2488    #include <boost/chrono/time_point.hpp>
2489    #include <boost/chrono/system_clocks.hpp>
2490    #include <boost/chrono/typeof/boost/chrono/chrono.hpp>
2491
2492[section:limitations Limitations and Extensions]
2493
2494At present, there is no know limitation respect to the C++11 standard.
2495
2496The current implementation provides in addition:
2497
2498* clock error handling as specified in [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3135.html#935 clock error handling needs to be specified].
2499* process and thread clocks.
2500
2501
2502[endsect] [/section:limitations Limitations and Extensions]
2503
2504[section:conf Configuration Macros]
2505
2506[section:assert How Assert Behaves?]
2507
2508When `BOOST_NO_CXX11_STATIC_ASSERT` is defined, the user can select the way static assertions are reported. Define
2509
2510* `BOOST_CHRONO_USES_STATIC_ASSERT`: define it if you want to use Boost.StaticAssert.
2511* `BOOST_CHRONO_USES_MPL_ASSERT`: define it if you want to use Boost.MPL static assertions.
2512* `BOOST_CHRONO_USES_ARRAY_ASSERT`: define it if you want to use internal static assertions.
2513
2514The default behavior is as `BOOST_CHRONO_USES_ARRAY_ASSERT` was defined.
2515
2516When `BOOST_CHRONO_USES_MPL_ASSERT` is not defined the following symbols are defined as
2517
2518    #define BOOST_CHRONO_A_DURATION_REPRESENTATION_CAN_NOT_BE_A_DURATION \
2519        "A duration representation can not be a duration"
2520    #define BOOST_CHRONO_SECOND_TEMPLATE_PARAMETER_OF_DURATION_MUST_BE_A_STD_RATIO \
2521        "Second template parameter of duration must be a boost::ratio"
2522    #define BOOST_CHRONO_DURATION_PERIOD_MUST_BE_POSITIVE \
2523        "duration period must be positive"
2524    #define BOOST_CHRONO_SECOND_TEMPLATE_PARAMETER_OF_TIME_POINT_MUST_BE_A_BOOST_CHRONO_DURATION \
2525        "Second template parameter of time_point must be a boost::chrono::duration"
2526
2527Depending on the static assertion used system you will have an hint of the failing assertion either through the symbol or through the text.
2528
2529[endsect]
2530
2531[section:no_hybrid Don't provide Hybrid Error Handling]
2532
2533When `BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING` is defined the lib doesn't provides the hybrid error handling prototypes:
2534
2535  Clock::time_point Clock::now(system::error_code&ec=boost::throws());
2536
2537This allow to be closer to the standard and to avoid the Boost.System dependency, making possible to have Boost.Chrono as a header-only library.
2538
2539By default `BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING` is defined.
2540
2541[endsect] [/section:header_only How to Build Boost.Chrono as a Header Only Library?]
2542
2543[section:header_only How to Build Boost.Chrono as a Header Only Library?]
2544
2545When `BOOST_CHRONO_HEADER_ONLY` is defined the lib is header-only.
2546
2547If in addition `BOOST_USE_WINDOWS_H` is defined `<windows.h>` is included, otherwise files in `boost/detail/win` are used to reduce the impact of including `<windows.h>`.
2548
2549However, you will either need to define `BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING` or link with Boost.System.
2550
2551[endsect] [/section:header_only How to Build Boost.Chrono as a Header Only Library?]
2552
2553[section:deprecated_io Deprecated IO]
2554
2555Version 2.0.0 deprecates the preceding IO features.
2556
2557However the default version is always version 1.
2558If you don't want to include the deprecated features you could define `BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0`.
2559
2560[/
2561These deprecated features will be provided by default up to boost 1.55.
2562Since 1.55 these features will not be included any more by default.
2563Since this version, if you want to include the deprecated features yet you could define `BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0`.
2564These id features will be only available until boost 1.58, that is you have 1 year and a half to move to the new features.
2565]
2566
2567[endsect]
2568
2569
2570[section:system_clock_time_point time_point<system_clock,D> specialization limitation]
2571
2572[/warning
2573
2574The time_point<system_clock,D> formatter/parser specializations don't work yet. It has been disable defining `BOOST_CHRONO_DONT_PROVIDE_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT` until a fix for the following ticket is found:
2575
2576- [@http://svn.boost.org/trac/boost/ticket/7547 #7547] time_point<system_clock> input version 2 fails to compile
2577
2578- [@http://svn.boost.org/trac/boost/ticket/7546 #7546] time_point<system_clock> output version 2 fails to compile
2579
2580In this case the io operators behave like any time_point as if the specialization was removed.
2581
2582In order to enable this features on compilers working with, you will need to define `BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT`.
2583
2584]
2585
2586[endsect]
2587
2588[section:version Version]
2589
2590`BOOST_CHRONO_VERSION` defines the Boost.Chrono version.
2591The default version is 1. In this case the following breaking or extending macros are defined if the opposite is not requested:
2592
2593* `BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0`
2594
2595The user can request the version 2 by defining `BOOST_CHRONO_VERSION` to 2. In this case the following breaking or extending macros are defined if the opposite is not requested:
2596
2597* Breaking change `BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 `
2598
2599The default value for `BOOST_CHRONO_VERSION` will be changed to 2 since Boost 1.55.
2600
2601[endsect]
2602
2603
2604[endsect] [/section:conf Configuration Macros]
2605
2606[endsect] [/section:chrono_hpp Header `<boost/chrono.hpp>`]
2607
2608
2609[/=============================================]
2610[section:duration_hpp Header `<boost/chrono/duration.hpp>`]
2611[/=============================================]
2612
2613This file contains duration specific classes and non-member functions.
2614
2615    namespace boost {
2616      namespace chrono {
2617
2618        template <class Rep, class Period = __ratio<1> >  class __duration;
2619
2620      }
2621      template <class Rep1, class Period1, class Rep2, class Period2>
2622      struct __common_type_spe<duration<Rep1, Period1>,
2623                         duration<Rep2, Period2> >;
2624
2625      namespace chrono {
2626
2627        // customization traits
2628        template <class Rep> struct __treat_as_floating_point;
2629        template <class Rep> struct __duration_values;
2630
2631        // duration arithmetic
2632        template <class Rep1, class Period1, class Rep2, class Period2>
2633        constexpr
2634        typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
2635        __duration__op_plus_1(
2636            const duration<Rep1, Period1>& lhs,
2637            const duration<Rep2, Period2>& rhs);
2638
2639        template <class Rep1, class Period1, class Rep2, class Period2>
2640        constexpr
2641        typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
2642        __duration__op_minus_1(
2643            const duration<Rep1, Period1>& lhs,
2644            const duration<Rep2, Period2>& rhs);
2645
2646        template <class Rep1, class Period, class Rep2>
2647        constexpr
2648        duration<typename common_type<Rep1, Rep2>::type, Period>
2649        __duration__op_mult_1(
2650            const duration<Rep1, Period>& d,
2651            const Rep2& s);
2652
2653        template <class Rep1, class Period, class Rep2>
2654        constexpr
2655        duration<typename common_type<Rep1, Rep2>::type, Period>
2656        __duration__op_mult_2(
2657            const Rep1& s,
2658            const duration<Rep2, Period>& d);
2659
2660        template <class Rep1, class Period, class Rep2>
2661        constexpr
2662        duration<typename common_type<Rep1, Rep2>::type, Period>
2663        __duration__op_div_2(
2664            const duration<Rep1, Period>& d,
2665            const Rep2& s);
2666
2667        template <class Rep1, class Period1, class Rep2, class Period2>
2668        constexpr
2669        typename common_type<Rep1, Rep2>::type
2670        __duration__op_div_3(
2671            const duration<Rep1, Period1>& lhs,
2672            const duration<Rep2, Period2>& rhs);
2673
2674        #ifdef BOOST_CHRONO_EXTENSIONS
2675        // Used to get frequency of events
2676        template <class Rep1, class Rep2, class Period>
2677        constexpr
2678        double __duration__op_div_1(
2679            const Rep1& s,
2680            const duration<Rep2, Period>& d);
2681        #endif
2682
2683        // duration comparisons
2684        template <class Rep1, class Period1, class Rep2, class Period2>
2685        constexpr bool __duration__op_eq_1(
2686            const duration<Rep1, Period1>& lhs,
2687            const duration<Rep2, Period2>& rhs);
2688
2689        template <class Rep1, class Period1, class Rep2, class Period2>
2690        constexpr bool __duration__op_neq_1(
2691            const duration<Rep1, Period1>& lhs,
2692            const duration<Rep2, Period2>& rhs);
2693
2694        template <class Rep1, class Period1, class Rep2, class Period2>
2695        constexpr bool __duration__op_le_1(
2696            const duration<Rep1, Period1>& lhs,
2697            const duration<Rep2, Period2>& rhs);
2698        template <class Rep1, class Period1, class Rep2, class Period2>
2699        constexpr bool __duration__op_leq_1(
2700            const duration<Rep1, Period1>& lhs,
2701            const duration<Rep2, Period2>& rhs);
2702
2703        template <class Rep1, class Period1, class Rep2, class Period2>
2704        constexpr bool __duration__op_gt_1(
2705            const duration<Rep1, Period1>& lhs,
2706            const duration<Rep2, Period2>& rhs);
2707        template <class Rep1, class Period1, class Rep2, class Period2>
2708        constexpr bool __duration__op_geq_1(
2709            const duration<Rep1, Period1>& lhs,
2710            const duration<Rep2, Period2>& rhs);
2711
2712        // duration_cast
2713
2714        template <class ToDuration, class Rep, class Period>
2715        constexpr
2716        ToDuration __duration_cast(const duration<Rep, Period>& d);
2717
2718        // convenience typedefs
2719        typedef duration<boost::int_least64_t, nano> __nanoseconds;    // at least 64 bits needed
2720        typedef duration<boost::int_least64_t, micro> __microseconds;  // at least 55 bits needed
2721        typedef duration<boost::int_least64_t, milli> __milliseconds;  // at least 45 bits needed
2722        typedef duration<boost::int_least64_t> __seconds;              // at least 35 bits needed
2723        typedef duration<boost::int_least32_t, ratio< 60> > __minutes; // at least 29 bits needed
2724        typedef duration<boost::int_least32_t, ratio<3600> > __hours;  // at least 23 bits needed
2725
2726      }
2727    }
2728
2729
2730[section:traits Time-related Traits]
2731
2732[section:treat_as_floating_point Metafunction `treat_as_floating_point<>`]
2733
2734    template <class Rep> struct treat_as_floating_point
2735        : boost::is_floating_point<Rep> {};
2736
2737The __duration template uses the __treat_as_floating_point trait to help determine if a __duration with one tick period can be converted to another __duration with a different tick period. If `treat_as_floating_point<Rep>::value` is `true`, then `Rep` is a floating-point type and implicit conversions are allowed among __durations. Otherwise, the implicit convertibility depends on the tick periods of the __durations. If `Rep` is a class type which emulates a floating-point type, the author of `Rep` can specialize __treat_as_floating_point so that __duration will treat this `Rep` as if it were a floating-point type. Otherwise `Rep` is assumed to be an integral type, or a class emulating an integral type.
2738
2739
2740[endsect]
2741[section:duration_values Class Template `duration_values`]
2742
2743    template <class Rep>
2744    struct duration_values
2745    {
2746    public:
2747        static constexpr Rep __zero();
2748        static constexpr Rep __max();
2749        static constexpr Rep __min();
2750    };
2751
2752The __duration template uses the __duration_values trait to construct special values of the __duration_s representation (`Rep`). This is done because the representation might be a class type with behavior which requires some other implementation to return these special values. In that case, the author of that class type should specialize __duration_values to return the indicated values.
2753
2754[section:zero Static Member Function `zero()`]
2755
2756    static constexpr Rep zero();
2757
2758__returns `Rep(0)`. [*Note:] `Rep(0)` is specified instead of `Rep()` since `Rep()` may have some other meaning, such as an uninitialized value.
2759
2760__remarks The value returned corresponds to the additive identity.
2761
2762[endsect]
2763[section:max Static Member Function `max()`]
2764
2765    static constexpr Rep max();
2766
2767__returns `numeric_limits<Rep>::max()`.
2768
2769__remarks The value returned compares greater than zero().
2770
2771[endsect]
2772[section:min Static Member Function `min()`]
2773
2774    static constexpr Rep min();
2775
2776__returns `numeric_limits<Rep>::lowest()`.
2777
2778__remarks The value returned compares less than or equal to `zero()`.
2779
2780[endsect]
2781
2782[endsect]
2783
2784[endsect]
2785
2786[section:common_type_spe `common_type` Specialization]
2787
2788    template <class Rep1, class Period1, class Rep2, class Period2>
2789    struct __common_type<chrono::__duration<Rep1, Period1>, chrono::__duration<Rep2, Period2> >
2790    {
2791        typedef chrono::__duration<typename __common_type<Rep1, Rep2>::type, __see_bellow__> type;
2792    };
2793
2794The period of the __duration indicated by this specialization of __common_type is the greatest common divisor of `Period1` and `Period2`. This can be computed by forming a __ratio of the greatest common divisor of `Period1::num` and `Period2::num`, and the least common multiple of `Period1::den` and `Period2::den`.
2795
2796[*Note:] The typedef type is the __duration with the largest tick period possible where both __duration arguments will convert to it without requiring a division operation. The representation of this type is intended to be able to hold any value resulting from this conversion, with the possible exception of round-off error when floating-point __durations are involved (but not truncation error).
2797
2798[endsect]
2799
2800
2801[section:duration Class Template `duration<>`]
2802
2803A __duration measures time between two points in time (__time_point). A __duration has a representation which holds a count of ticks, and a tick period. The tick period is the amount of time which occurs from one tick to another in units of a second. It is expressed as a rational constant using __ratio.
2804
2805    namespace boost { namespace chrono {
2806
2807        template <class Rep, class Period>
2808        class duration {
2809        public:
2810            typedef Rep rep;
2811            typedef Period period;
2812        private:
2813            rep rep_; // exposition only
2814        public:
2815            constexpr __duration__c_0();
2816            template <class Rep2>
2817            constexpr explicit __duration__c_1(const Rep2& r);
2818
2819            template <class Rep2, class Period2>
2820            constexpr __duration__c_2(const duration<Rep2, Period2>& d);
2821
2822            duration& operator=(const duration&) = default;
2823
2824            constexpr rep __duration__count() const;
2825
2826            constexpr duration  __duration__op_plus();
2827            constexpr duration  __duration__op_minus();
2828            duration& __duration__op_pre_inc();
2829            duration  __duration__op_post_inc(int);
2830            duration& __duration__op_pre_dec();
2831            duration  __duration__op_post_dec(int);
2832
2833            duration& __duration__op_plus_eq(const duration& d);
2834            duration& __duration__op_minus_eq(const duration& d);
2835
2836            duration& __duration__op_mult_eq(const rep& rhs);
2837            duration& __duration__op_div_eq(const rep& rhs);
2838            duration& __duration__op_mod_eq(const rep& rhs);
2839            duration& __duration__op_mod_eq2(const duration& rhs);
2840
2841            static constexpr duration __duration__zero();
2842            static constexpr duration __duration__min();
2843            static constexpr duration __duration__max();
2844        };
2845
2846    }}
2847
2848`Rep` must be an arithmetic type, or a class emulating an arithmetic type, compile diagnostic otherwise. If __duration is instantiated with the type of `Rep` being a __duration, compile diagnostic is issued.
2849
2850`Period` must be an instantiation of `ratio`, compile diagnostic otherwise.
2851
2852`Period::num` must be positive, compile diagnostic otherwise.
2853
2854Examples:
2855
2856* `__duration<long, __ratio<60> >` holds a count of minutes using a long.
2857
2858* `__duration<long long, milli>` holds a count of milliseconds using a long long.
2859
2860* `__duration<double, __ratio<1, 30> >` holds a count using a double with a tick period of 1/30 second (a tick frequency of 30 Hz).
2861
2862The following members of __duration do not throw an exception unless the indicated operations on the representations throw an exception.
2863
2864[section:duration_c_0 Constructor `duration()`]
2865
2866            constexpr duration();
2867
2868__effects  Constructs an object of type __duration initialized from `duration_values<rep>::zero()` in C++98 or `BOOST_CHRONO_DURATION_DEFAULTS_TO_ZERO` is defined, otherwise the duration is uninitialized.
2869
2870[endsect]
2871
2872[section:duration_c_1 Constructor `duration(const Rep2&)`]
2873
2874    template <class Rep2>
2875    constexpr explicit duration(const Rep2& r);
2876
2877__remarks `Rep2` is implicitly convertible to `rep`, and
2878
2879* `treat_as_floating_point<rep>::value` is `true`, or
2880* `!treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value` is `true`.
2881
2882If these constraints are not met, this constructor will not participate in overload resolution. [*Note:] This requirement prevents construction of an integral-based __duration with a floating-point representation. Such a construction could easily lead to confusion about the value of the __duration.
2883
2884__example
2885
2886        __duration<int, milli> d(3.5);  // do not compile
2887        __duration<int, milli> d(3);    // ok
2888
2889__effects  Constructs an object of type __duration.
2890
2891__post_conditions `count() == static_cast<rep>(r)`.
2892
2893[endsect]
2894[section:duration_c_2 Constructor `duration(const duration&)`]
2895
2896    template <class Rep2, class Period2>
2897    constexpr __duration(const __duration<Rep2, Period2>& d);
2898
2899__remarks `treat_as_floating_point<rep>::value`, or `ratio_divide<Period2, period>::type::den == 1`, else this constructor will not participate in overload resolution. [*note] This requirement prevents implicit truncation error when converting between integral-based __durations. Such a construction could easily lead to confusion about the value of the __duration.
2900
2901__example
2902
2903        __duration<int, milli> ms(3);
2904        __duration<int, micro> us = ms;  // ok
2905        __duration<int, milli> ms2 = us; // do not compile
2906
2907__effects  Constructs an object of type __duration, constructing `rep_` from `duration_cast<__duration>(d).count()`.
2908
2909[endsect]
2910[section:count Member Function `count() const`]
2911
2912    constexpr rep count() const;
2913
2914__returns `rep_`.
2915
2916[endsect]
2917[section:op_unary_plus Member Function `operator+() const`]
2918
2919    constexpr __duration operator+() const;
2920
2921__returns `*this`.
2922
2923[endsect]
2924[section:op_unary_minus Member Function `operator-() const`]
2925
2926    constexpr __duration operator-() const;
2927
2928__returns `__duration(-rep_)`.
2929
2930[endsect]
2931[section:op_pre_inc Member Function `operator++()`]
2932
2933    __duration& operator++();
2934
2935__effects  `++rep_`.
2936
2937__returns `*this`.
2938
2939[endsect]
2940[section:op_post_inc Member Function `operator++(int)`]
2941
2942    __duration operator++(int);
2943
2944__returns `__duration(rep_++)`.
2945
2946[endsect]
2947[section:op_pre_dec Member Function `operator--()`]
2948
2949    __duration& operator--();
2950
2951__effects  `--rep_`.
2952
2953__returns `*this`.
2954
2955[endsect]
2956[section:op_post_dec Member Function `operator--(int)`]
2957
2958    __duration operator--(int);
2959
2960__returns `__duration(rep_--)`.
2961
2962[endsect]
2963[section:op_plus_eq Member Function `operator+=(const duration&)`]
2964
2965    __duration& operator+=(const __duration& d);
2966
2967__effects  `rep_ += d.count()`.
2968
2969__returns `*this`.
2970
2971[endsect]
2972[section:op_minus_eq Member Function `operator-=(const duration&)`]
2973
2974    __duration& operator-=(const __duration& d);
2975
2976__effects  `rep_ -= d.count()`.
2977
2978__returns `*this`.
2979
2980[endsect]
2981[section:op_mod_eq Member Function `operator%=(const duration&)`]
2982
2983    __duration& operator%=(const __duration& d);
2984
2985__effects  `rep_ %= d.count()`.
2986
2987__returns `*this`.
2988
2989[endsect]
2990[section:op_mult_eq Member Function `operator*=(const rep&)`]
2991
2992    __duration& operator*=(const rep& rhs);
2993
2994__effects  `rep_ *= rhs`.
2995
2996__returns `*this`.
2997
2998[endsect]
2999[section:op_div_eq Member Function `operator/=(const rep&)`]
3000
3001    __duration& operator/=(const rep& rhs);
3002
3003__effects  `rep_ /= rhs`.
3004
3005__returns `*this`.
3006
3007[endsect]
3008[section:op_mod_eq2 Member Function `operator%=(const rep&)`]
3009
3010    __duration& operator%=(const rep& rhs);
3011
3012__effects  `rep_ %= rhs`.
3013
3014__returns `*this`.
3015
3016[endsect]
3017
3018
3019[section:zero Static Member Function `zero()`]
3020
3021    static constexpr __duration zero();
3022
3023__returns `__duration(__duration_values<rep>::zero())`.
3024
3025[endsect]
3026[section:min Static Member Function `min()`]
3027
3028    static constexpr __duration min();
3029
3030__returns `__duration(__duration_values<rep>::min()).`
3031
3032[endsect]
3033[section:max Static Member Function `max()`]
3034
3035    static constexpr __duration max();
3036
3037__returns `__duration(__duration_values<rep>::max())`.
3038
3039[endsect]
3040
3041[endsect]
3042
3043
3044[section:arith `duration` Non-Member Arithmetic]
3045
3046[section:duration__op_plus_1 Non-Member Function `operator+(duration,duration)`]
3047
3048    template <class Rep1, class Period1, class Rep2, class Period2>
3049    constexpr
3050    typename __common_type<__duration<Rep1, Period1>, __duration<Rep2, Period2> >::type
3051    operator+(const __duration<Rep1, Period1>& lhs, const __duration<Rep2, Period2>& rhs);
3052
3053__returns `CD(CD(lhs).count() + CD(rhs).count())` where `CD` is the type of the return value.
3054
3055[endsect]
3056[section:duration__op_minus_1 Non-Member Function `operator-(duration,duration)`]
3057
3058    template <class Rep1, class Period1, class Rep2, class Period2>
3059    constexpr
3060    typename __common_type<__duration<Rep1, Period1>, __duration<Rep2, Period2> >::type
3061    operator-(const __duration<Rep1, Period1>& lhs, const __duration<Rep2, Period2>& rhs);
3062
3063__returns `CD(CD(lhs).count() - CD(rhs).count())` where `CD` is the type of the return value.
3064
3065[endsect]
3066[section:duration__op_mult_1 Non-Member Function `operator*(duration,Rep1)`]
3067
3068    template <class Rep1, class Period, class Rep2>
3069    constexpr
3070    __duration<typename __common_type<Rep1, Rep2>::type, Period>
3071    operator*(const __duration<Rep1, Period>& d, const Rep2& s);
3072
3073__requires Let `CR` represent the __common_type of `Rep1` and `Rep2`. This function will not participate in overload resolution unless both `Rep1` and `Rep2` are implicitly convertible to `CR`.
3074
3075__returns `CD(CD(d).count() * s)` where `CD` is the type of the return value.
3076
3077[endsect]
3078[section:duration__op_mult_2 Non-Member Function `operator*(Rep1,duration)`]
3079
3080    template <class Rep1, class Period, class Rep2>
3081    constexpr
3082    __duration<typename __common_type<Rep1, Rep2>::type, Period>
3083    operator*(const Rep1& s, const __duration<Rep2, Period>& d);
3084
3085__requires Let `CR` represent the __common_type of `Rep1` and `Rep2`. This function will not participate in overload resolution unless both `Rep1` and `Rep2` are implicitly convertible to `CR`.
3086
3087__returns `d * s`.
3088
3089[endsect]
3090
3091
3092[section:duration__op_div_1 Non-Member Function `operator/(duration,Rep2)`]
3093
3094    template <class Rep1, class Period, class Rep2>
3095    constexpr
3096    __duration<typename __common_type<Rep1, Rep2>::type, Period>
3097    operator/(const __duration<Rep1, Period>& d, const Rep2& s);
3098
3099__requires Let `CR` represent the __common_type of `Rep1` and `Rep2`. This function will not participate in overload resolution unless both `Rep1` and `Rep2` are implicitly convertible to `CR`, and `Rep2` is  not an instantiation of __duration.
3100
3101__returns `CD(CD(d).count() / s)` where `CD` is the type of the return value.
3102
3103[endsect]
3104[section:duration__op_div_2 Non-Member Function `operator/(duration,duration)`]
3105
3106    template <class Rep1, class Period1, class Rep2, class Period2>
3107    constexpr
3108    typename __common_type<Rep1, Rep2>::type
3109    operator/(const __duration<Rep1, Period1>& lhs, const __duration<Rep2, Period2>& rhs);
3110
3111__remarks Let `CD` represent the __common_type of the two __duration arguments.
3112__returns Returns `CD(lhs).count() / CD(rhs).count()`.
3113
3114[endsect]
3115
3116[section:duration__op_div_3 Non-Member Function `operator/(Rep1,duration)`]
3117
3118Included only if BOOST_CHRONO_EXTENSIONS is defined.
3119
3120This overloading could be used to get the frequency of an event counted by `Rep1`.
3121
3122    template <class Rep1, class Rep2, class Period>
3123    constexpr
3124    double operator/(const Rep1& s, const __duration<Rep2, Period>& d);
3125
3126__remarks Let `CR` represent the __common_type of `Rep1` and `Rep2`. This function will not participate in overload resolution unless both `Rep1` and `Rep2` are implicitly convertible to `CR`, and `Rep1` is  not an instantiation of __duration. Let `CD` represent __duration<CR,Period>.
3127
3128__returns `CR(s)/CD(d).count()` where `CD` is the type of the return value.
3129
3130
3131[endsect]
3132
3133
3134[section:duration__op_mod_1 Non-Member Function `operator%(duration,Rep2)`]
3135
3136  template <class Rep1, class Period, class Rep2>
3137  constexpr
3138  __duration<typename __common_type<Rep1, Rep2>::type, Period>
3139  operator%(const __duration<Rep1, Period>& d, const Rep2& s);
3140
3141__remarks Let `CR` represent the __common_type of `Rep1` and `Rep2`. This function will not participate in overload resolution unless Rep2 must be implicitly convertible to CR and Rep2 must not be an instantiation of __duration.
3142
3143__returns CD(CD(d).count() % s) where `CD` is the type of the return value.
3144
3145[endsect]
3146
3147[section:duration__op_mod_2 Non-Member Function `operator%(duration,duration)`]
3148
3149  template <class Rep1, class Period1, class Rep2, class Period2>
3150  constexpr
3151  typename __common_type<__duration<Rep1, Period1>, __duration<Rep2, Period2> >::type
3152  operator%(const __duration<Rep1, Period1>& lhs,
3153            const __duration<Rep2, Period2>& rhs);
3154
3155__remarks This function will not participate in overload resolution unless
3156
3157__returns CD(CD(lhs).count() % CD(rhs).count()) where `CD` is the type of the return value.
3158
3159[endsect]
3160[endsect]
3161
3162[section:cmp `duration` Non-Member Comparaisons]
3163
3164[section:duration__op_eq_1 Non-Member Function `operator==(duration,duration)`]
3165
3166    template <class Rep1, class Period1, class Rep2, class Period2>
3167    bool operator==(const __duration<Rep1, Period1>& lhs,
3168                    const __duration<Rep2, Period2>& rhs);
3169
3170__returns Let `CD` represent the __common_type of the two __duration arguments.
3171
3172__returns Returns `CD(lhs).count() == CD(rhs).count()`
3173
3174[endsect]
3175[section:duration__op_neq_1 Non-Member Function `operator!=(duration,duration)`]
3176
3177    template <class Rep1, class Period1, class Rep2, class Period2>
3178    bool operator!=(const __duration<Rep1, Period1>& lhs,
3179                    const __duration<Rep2, Period2>& rhs);
3180
3181__returns `!(lhs == rhs)`.
3182
3183[endsect]
3184[section:duration__op_lt_1 Non-Member Function `operator<(duration,duration)`]
3185
3186    template <class Rep1, class Period1, class Rep2, class Period2>
3187    bool operator< (const __duration<Rep1, Period1>& lhs,
3188                    const __duration<Rep2, Period2>& rhs);
3189
3190__returns Let `CD` represent the __common_type of the two __duration arguments. Returns `CD(lhs).count() < CD(rhs).count()`
3191
3192[endsect]
3193[section:duration__op_leq_1 Non-Member Function `operator<=(duration,duration)`]
3194
3195    template <class Rep1, class Period1, class Rep2, class Period2>
3196    bool operator<=(const __duration<Rep1, Period1>& lhs,
3197                    const __duration<Rep2, Period2>& rhs);
3198
3199__returns `!(rhs < lhs)`.
3200
3201[endsect]
3202[section:duration__op_gt_1 Non-Member Function `operator>(duration,duration)`]
3203
3204    template <class Rep1, class Period1, class Rep2, class Period2>
3205    bool operator> (const __duration<Rep1, Period1>& lhs,
3206                    const __duration<Rep2, Period2>& rhs);
3207
3208__returns `rhs < lhs`.
3209
3210[endsect]
3211[section:duration__op_geq_1 Non-Member Function `operator>=(duration,duration)`]
3212
3213    template <class Rep1, class Period1, class Rep2, class Period2>
3214    bool operator>=(const __duration<Rep1, Period1>& lhs,
3215                    const __duration<Rep2, Period2>& rhs);
3216
3217__returns `!(lhs < rhs)`.
3218
3219[endsect]
3220[endsect]
3221[section:duration_cast Non-Member Function `duration_cast(duration)`]
3222
3223    template <class __ToDuration, class Rep, class Period>
3224    __ToDuration duration_cast(const __duration<Rep, Period>& d);
3225
3226__requires This function will not participate in overload resolution unless `ToDuration` is an instantiation of __duration.
3227
3228__returns Forms `CF` which is a __ratio resulting from `ratio_divide<Period, typename ToDuration::period>::type`. Let `CR` be the __common_type of `ToDuration::rep`, `Rep`, and `intmax_t`.
3229
3230* If `CF::num == 1` and `CF::den == 1`, then returns `ToDuration(static_cast<typename ToDuration::rep>(d.count())) `
3231* else if `CF::num != 1` and `CF::den == 1`, then returns
3232              `ToDuration(static_cast<typename ToDuration::rep>(static_cast<CR>(d.count()) *
3233                                                               static_cast<CR>(CF::num)))`
3234* else if `CF::num == 1` and `CF::den != 1`, then returns
3235              `ToDuration(static_cast<typename ToDuration::rep>(static_cast<CR>(d.count()) /
3236                                                               static_cast<CR>(CF::den)))`
3237* else returns
3238              `ToDuration(static_cast<typename ToDuration::rep>(static_cast<CR>(d.count()) *
3239                                                               static_cast<CR>(CF::num)   /
3240                                                               static_cast<CR>(CF::den)))`
3241
3242__remarks This function does not rely on any implicit conversions. All conversions must be accomplished through `static_cast`. The implementation avoids all multiplications or divisions when it is known at compile-time that it can be avoided because one or more arguments are `1`. All intermediate computations are carried out in the widest possible representation and only converted to the destination representation at the final step.
3243
3244
3245[endsect]
3246
3247
3248[section:duration_typedefs `duration` typedefs]
3249
3250        // convenience typedefs
3251        typedef __duration<boost::int_least64_t, nano> nanoseconds;    // at least 64 bits needed
3252        typedef __duration<boost::int_least64_t, micro> microseconds;  // at least 55 bits needed
3253        typedef __duration<boost::int_least64_t, milli> milliseconds;  // at least 45 bits needed
3254        typedef __duration<boost::int_least64_t> seconds;              // at least 35 bits needed
3255        typedef __duration<boost::int_least32_t, __ratio< 60> > minutes; // at least 29 bits needed
3256        typedef __duration<boost::int_least32_t, __ratio<3600> > hours;  // at least 23 bits needed
3257
3258[endsect]
3259
3260[endsect]
3261
3262[section:clock `Clock` Requirements]
3263
3264A clock represents a bundle consisting of a  __duration, a  __time_point, and a function `now()` to get the current __time_point. A clock must meet the requirements in the following Table.
3265
3266In this table `C1` and `C2` denote `Clock` types. `t1` and `t2` are values returned from `C1::now()` where the call returning `t1` happens before the call returning `t2` and both of these calls occur before `C1::time_point::max()`.
3267(note This means C1 did not wrap around between t1 and t2.).
3268
3269[table Clock Requirements
3270    [[expression]        [return type]  [operational semantics]]
3271    [[`C1::rep`]        [An arithmetic type or class emulating an arithmetic type. ]  [The representation type of the  __duration and __time_point.]]
3272    [[`C1::period`]        [`ratio`]  [The tick period of the clock in seconds.]]
3273    [[`C1::duration`]        [`chrono::duration<C1::rep, C1::period>`]  [The  __duration type of the `clock`.]]
3274    [[`C1::time_point`]        [`chrono::time_point<C1> or chrono::time_point<C2, C1::duration>`]  [The  __time_point type of the `clock`. Different clocks are permitted to share a __time_point definition if it is valid to compare their time_points by comparing their respective __durations. `C1` and `C2` must refer to the same epoch.]]
3275    [[`C1::is_steady`]        [`constexpr bool`]  [`true` if `t1 <= t2` is always `true`, else `false`. *Note*: A `clock` that can be adjusted backwards is not steady]]
3276    [[`C1::now()`]        [`C1::time_point`]  [Returns a __time_point representing the current point in time.]]
3277]
3278
3279Models of __Clock:
3280
3281* __system_clock
3282* __steady_clock
3283* __high_resolution_clock
3284* __process_real_cpu_clock
3285* __process_user_cpu_clock
3286* __process_system_cpu_clock
3287* __process_cpu_clock
3288* __thread_clock
3289
3290[endsect]
3291
3292[section:trivial_clock `TrivialClock` Requirements]
3293
3294A type `TC` meets the `TrivialClock` requirements if:
3295
3296* `TC` satisfies the `Clock` requirements,
3297* the types `TC::rep`, `TC::duration`, and `TC::time_point` satisfy the requirements of `EqualityComparable`, `LessThanComparable`, `DefaultConstructible`, `CopyConstructible`, `CopyAssignable`, `Destructible`, and the requirements of numeric types.
3298
3299[note This means, in particular, that operations on these types will not throw exceptions.]
3300
3301* lvalues of the types `TC::rep`, `TC::duration`, and `TC::time_point` are swappable,
3302* the function `TC::now()` does not throw exceptions and it is thread-safe, and
3303* the type `TC::time_point::clock` meets the `TrivialClock` requirements, recursively.
3304
3305Models of __TrivialClock:
3306
3307* __system_clock
3308* __steady_clock
3309* __high_resolution_clock
3310* __process_real_cpu_clock
3311* __process_user_cpu_clock
3312* __process_system_cpu_clock
3313* __thread_clock
3314
3315[endsect]
3316
3317[section:ecclock `EcClock` Requirements]
3318
3319A type `EcC` meets the `EcClock` requirements if
3320
3321* `TC` satisfies the `TrivialClock ` requirements, and
3322* it adds `now()` interfaces allowing to recover internal error codes as described in the following table.
3323* the added now() function is thread-safe.
3324
3325In this table `C1` denotes a `EcClock` type and `ec` is an instance of a `boost::system::error_code`.
3326
3327[table Clock Requirements
3328    [[expression]        [return type]  [operational semantics]]
3329    [[`C1::now(ec)`]        [`C1::time_point`]  [Returns a __time_point representing the current point in time. `ec` will stores the error-code in case something was wrong internally.]]
3330    [[`C1::now(boost::throws())`]        [`C1::time_point`]  [Returns a __time_point representing the current point in time.
3331    Throws a `boost::system::system_error` exception in case something was wrong internally.]]
3332]
3333
3334Models of __Clock:
3335
3336* __system_clock
3337* __steady_clock
3338* __high_resolution_clock
3339* __process_real_cpu_clock
3340* __process_user_cpu_clock
3341* __process_system_cpu_clock
3342* __process_cpu_clock
3343* __thread_clock
3344
3345[endsect]
3346
3347
3348[/=============================================]
3349[section:time_point_hpp Header `<boost/chrono/time_point.hpp>`]
3350[/=============================================]
3351
3352This file contains __time_point specific classes and non-member functions.
3353
3354    namespace boost {
3355      namespace chrono {
3356
3357        template <class __Clock, class __Duration = typename Clock::duration>
3358        class __time_point;
3359
3360      }
3361      template <class __Clock, class __Duration1, class __Duration2>
3362      struct __common_type_spe<time_point<Clock, Duration1>,
3363                         time_point<Clock, Duration2> >;
3364
3365      namespace chrono {
3366
3367        // time_point arithmetic
3368        template <class __Clock, class __Duration1, class Rep2, class Period2>
3369        constexpr time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2> >::type>
3370        __time_point__op_plus_1(const time_point<Clock, Duration1>& lhs,
3371                  const duration<Rep2, Period2>& rhs);
3372
3373        template <class Rep1, class Period1, class __Clock, class __Duration2>
3374        constexpr time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
3375        __time_point__op_plus_2(const duration<Rep1, Period1>& lhs,
3376                  const time_point<Clock, Duration2>& rhs);
3377
3378        template <class __Clock, class __Duration1, class Rep2, class Period2>
3379        constexpr time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2> >::type>
3380        __time_point__op_minus_1(const time_point<Clock, Duration1>& lhs,
3381                  const duration<Rep2, Period2>& rhs);
3382
3383        template <class __Clock, class __Duration1, class __Duration2>
3384        constexpr typename common_type<Duration1, Duration2>::type
3385        __time_point__op_minus_2(const time_point<Clock, Duration1>& lhs,
3386                  const time_point<Clock, Duration2>& rhs);
3387
3388        // time_point comparisons
3389        template <class __Clock, class __Duration1, class __Duration2>
3390        constexpr bool
3391        __time_point__op_eq(const time_point<Clock, Duration1>& lhs,
3392                   const time_point<Clock, Duration2>& rhs);
3393        template <class __Clock, class __Duration1, class __Duration2>
3394        constexpr bool
3395        __time_point__op_neq(const time_point<Clock, Duration1>& lhs,
3396                   const time_point<Clock, Duration2>& rhs);
3397        template <class __Clock, class __Duration1, class __Duration2>
3398        constexpr bool
3399        __time_point__op_lt(const time_point<Clock, Duration1>& lhs,
3400                  const time_point<Clock, Duration2>& rhs);
3401        template <class __Clock, class __Duration1, class __Duration2>
3402        constexpr bool
3403        __time_point__op_leq(const time_point<Clock, Duration1>& lhs,
3404                   const time_point<Clock, Duration2>& rhs);
3405        template <class __Clock, class __Duration1, class __Duration2>
3406        constexpr bool
3407        __time_point__op_gt(const time_point<Clock, Duration1>& lhs,
3408                  const time_point<Clock, Duration2>& rhs);
3409        template <class __Clock, class __Duration1, class __Duration2>
3410        constexpr bool
3411        __time_point__op_geq(const time_point<Clock, Duration1>& lhs,
3412                   const time_point<Clock, Duration2>& rhs);
3413
3414        // time_point_cast
3415        template <class __ToDuration, class __Clock, class __Duration>
3416        constexpr time_point<Clock, ToDuration>
3417        __time_point_cast(const time_point<Clock, Duration>& t);
3418
3419      }
3420    }
3421
3422
3423[section:common_type_spe2 `common_type` specialization]
3424
3425    template <class __Clock, class __Duration1, class __Duration2>
3426    struct __common_type<chrono::__time_point<__Clock, __Duration1>, chrono::__time_point<__Clock, __Duration2> >
3427    {
3428        typedef chrono::__time_point<__Clock, typename __common_type<Duration1, __Duration2>::type> type;
3429    };
3430
3431The __common_type of two __time_points is a __time_point with the same __Clock (both have the same __Clock), and the __common_type of the two __durations.
3432
3433[endsect]
3434
3435[section:time_point Class template `time_point<>`]
3436
3437A __time_point represents a point in time with respect to a specific clock.
3438
3439    template <class __Clock, class __Duration>
3440    class time_point {
3441    public:
3442        typedef Clock                     clock;
3443        typedef Duration                  duration;
3444        typedef typename duration::rep    rep;
3445        typedef typename duration::period period;
3446    private:
3447        duration d_; // exposition only
3448    public:
3449        constexpr __time_point__c_1();
3450
3451        constexpr explicit __time_point__c_2(const duration& d);
3452
3453        // conversions
3454        template <class __Duration2>
3455        constexpr
3456        __time_point__c_3(const time_point<clock, __Duration2>& t);
3457
3458        // observer
3459        constexpr duration __time_point__time_since_epoch() const;
3460
3461        // arithmetic
3462
3463        #ifdef BOOST_CHRONO_EXTENSIONS
3464        constexpr time_point  __time_point__op_unary_plus();
3465        constexpr time_point  __time_point__op_unary_minus();
3466        time_point& __time_point__op_pre_inc();
3467        time_point  __time_point__op_post_inc(int);
3468        time_point& __time_point__op_pre_dec();
3469        time_point  __time_point__op_post_dec(int);
3470
3471        time_point& __time_point__op_plus_eq_1(const rep& d);
3472        time_point& __time_point__op_minus_eq_1(const rep& d);
3473        #endif
3474
3475        time_point& __time_point__op_plus_eq_2(const duration& d);
3476        time_point& __time_point__op_minus_eq_2(const duration& d);
3477
3478        // special values
3479
3480        static constexpr time_point __time_point__min();
3481        static constexpr time_point __time_point__max();
3482    };
3483
3484Clock must meet the __clock_req.
3485
3486Duration must be an instantiation of __duration, compile diagnostic otherwise.
3487
3488[section:time_point_c_1 Constructor `time_point()`]
3489
3490    constexpr time_point();
3491
3492__effects  Constructs an object of __time_point, initializing `d_` with `duration::zero()`. This __time_point represents the epoch.
3493
3494[endsect]
3495[section:time_point_c_2 Constructor `time_point(const duration&)`]
3496
3497    constexpr time_point(const duration& d);
3498
3499__effects  Constructs an object of __time_point, initializing `d_` with `d`. This __time_point represents the epoch `+ d`.
3500
3501[endsect]
3502[section:time_point_c_3 Copy Constructor `time_point(const time_point&)`]
3503
3504    template <class __Duration2>
3505    constexpr
3506    time_point(const __time_point<clock, __Duration2>& t);
3507
3508__requires This function will not participate in overload resolution unless `Duration2` is implicitly convertible to __duration.
3509
3510__effects  Constructs an object of __time_point, initializing `d_` with `t.time_since_epoch()`.
3511
3512[endsect]
3513
3514[section:time_since_epoch Member Function `time_since_epoch() const`]
3515
3516    constexpr duration time_since_epoch() const;
3517
3518__returns `d_`.
3519
3520[endsect]
3521
3522[section:op_unary_plus Member Function `operator+() const`]
3523
3524    constexpr __time_point operator+() const;
3525
3526__returns `*this`.
3527
3528[endsect]
3529[section:op_unary_minus Member Function `operator-() const`]
3530
3531    constexpr __time_point operator-() const;
3532
3533__returns `__time_point(-d_)`.
3534
3535[endsect]
3536[section:op_pre_inc Member Function `operator++()`]
3537
3538    __time_point& operator++();
3539
3540__effects  `++d_`.
3541
3542__returns `*this`.
3543
3544[endsect]
3545[section:op_post_inc Member Function `operator++(int)`]
3546
3547    __time_point operator++(int);
3548
3549__returns `__time_point(d_++)`.
3550
3551[endsect]
3552[section:op_pre_dec Member Function `operator--()`]
3553
3554    __time_point& operator--();
3555
3556__effects  `--d_`.
3557
3558__returns `*this`.
3559
3560[endsect]
3561[section:op_post_dec Member Function `operator--(int)`]
3562
3563    __time_point operator--(int);
3564
3565__returns `__time_point(d_--)`.
3566
3567[endsect]
3568
3569[section:op_plus_eq_1 Member Function `operator+=(const rep&)`]
3570
3571    __time_point& operator+=(const rep& r);
3572
3573__effects  `d_ += duration(r)`.
3574
3575__returns `*this`.
3576
3577[endsect]
3578[section:op_minus_eq_1 Member Function `operator-=(const rep&)`]
3579
3580    __time_point& operator-=(const rep& r);
3581
3582__effects  `d_ -= duration(r)`
3583
3584__returns `*this`.
3585
3586[endsect]
3587
3588
3589[section:op_plus_eq_2 Member Function `operator+=`]
3590
3591    time_point& operator+=(const duration& d);
3592
3593__effects  `d_ += d`.
3594
3595__returns `*this`.
3596
3597[endsect]
3598[section:op_minus_eq_2 Member Function `operator-=`]
3599
3600    time_point& operator-=(const duration& d);
3601
3602__effects  `d_ -= d`
3603
3604__returns `*this`.
3605
3606[endsect]
3607[section:min Static Member Function `min`]
3608
3609    static constexpr time_point min();
3610
3611__returns `time_point(duration::min())`.
3612
3613[endsect]
3614[section:max Static Member Function `max`]
3615
3616    static constexpr time_point max();
3617
3618__returns `time_point(duration::max())`.
3619
3620[endsect]
3621[endsect]
3622
3623
3624[section:arith `time_point` non-member arithmetic]
3625
3626
3627[section:time_point__op_plus_1 Non-Member Function `operator+(time_point,duration)`]
3628
3629    template <class __Clock, class __Duration1, class Rep2, class Period2>
3630    constexpr
3631    __time_point<__Clock, typename __common_type<Duration1, duration<Rep2, Period2> >::type>
3632    operator+(const __time_point<__Clock, __Duration1>& lhs,
3633              const duration<Rep2, Period2>& rhs);
3634
3635__returns `CT(lhs.time_since_epoch() + rhs)` where `CT` is the type of the return value.
3636
3637[endsect]
3638[section:time_point__op_plus_2 Non-Member Function `operator+(duration,time_point)`]
3639
3640    template <class Rep1, class Period1, class __Clock, class __Duration2>
3641    constexpr
3642    __time_point<__Clock, typename __common_type<duration<Rep1, Period1>, __Duration2>::type>
3643    operator+(const duration<Rep1, Period1>& lhs,
3644              const __time_point<__Clock, __Duration2>& rhs);
3645
3646__returns `rhs + lhs`.
3647
3648[endsect]
3649[section:time_point__op_minus_1 Non-Member Function `operator-(time_point,duration)`]
3650
3651    template <class __Clock, class __Duration1, class Rep2, class Period2>
3652    constexpr
3653    __time_point<__Clock, typename __common_type<Duration1, duration<Rep2, Period2> >::type>
3654    operator-(const __time_point<__Clock, __Duration1>& lhs,
3655              const duration<Rep2, Period2>& rhs);
3656
3657__returns `lhs + (-rhs)`.
3658
3659[endsect]
3660[section:time_point__op_minus_2 Non-Member Function `operator-(time_point,time_point)`]
3661
3662    template <class __Clock, class __Duration1, class __Duration2>
3663    constexpr
3664    typename __common_type<Duration1, __Duration2>::type
3665    operator-(const __time_point<__Clock, __Duration1>& lhs,
3666              const __time_point<__Clock, __Duration2>& rhs);
3667
3668__returns `lhs.time_since_epoch() - rhs.time_since_epoch()`.
3669
3670[endsect]
3671[endsect]
3672
3673[section:cmp `time_point` non-member comparisons]
3674[section:time_point__op_eq Non-Member Function `operator==(time_point,time_point)`]
3675
3676    template <class __Clock, class __Duration1, class __Duration2>
3677    constexpr
3678    bool operator==(const __time_point<__Clock, __Duration1>& lhs,
3679                    const __time_point<__Clock, __Duration2>& rhs);
3680
3681__returns `lhs.time_since_epoch() == rhs.time_since_epoch()`.
3682
3683[endsect]
3684[section:time_point__op_neq Non-Member Function `operator!=(time_point,time_point)`]
3685
3686   template <class __Clock, class __Duration1, class __Duration2>
3687   constexpr
3688   bool operator!=(const __time_point<__Clock, __Duration1>& lhs,
3689                   const __time_point<__Clock, __Duration2>& rhs);
3690
3691__returns `!(lhs == rhs)`.
3692
3693[endsect]
3694[section:time_point__op_lt Non-Member Function `operator<(time_point,time_point)`]
3695
3696    template <class __Clock, class __Duration1, class __Duration2>
3697    constexpr
3698    bool operator< (const __time_point<__Clock, __Duration1>& lhs,
3699                    const __time_point<__Clock, __Duration2>& rhs);
3700
3701__returns lhs.time_since_epoch() < rhs.time_since_epoch().
3702
3703[endsect]
3704[section:time_point__op_leq Non-Member Function `operator<=(time_point,time_point)`]
3705
3706    template <class __Clock, class __Duration1, class __Duration2>
3707    constexpr
3708    bool operator<=(const __time_point<__Clock, __Duration1>& lhs,
3709                    const __time_point<__Clock, __Duration2>& rhs);
3710
3711__returns `!(rhs < lhs)`.
3712
3713[endsect]
3714[section:time_point__op_gt Non-Member Function `operator>(time_point,time_point)`]
3715
3716   template <class __Clock, class __Duration1, class __Duration2>
3717   constexpr
3718   bool operator>(const __time_point<__Clock, __Duration1>& lhs,
3719                  const __time_point<__Clock, __Duration2>& rhs);
3720
3721__returns `rhs < lhs`.
3722
3723[endsect]
3724[section:time_point__op_geq Non-Member Function `operator>=(time_point,time_point)`]
3725
3726    template <class __Clock, class __Duration1, class __Duration2>
3727    constexpr
3728    bool operator>=(const __time_point<__Clock, __Duration1>& lhs,
3729                    const __time_point<__Clock, __Duration2>& rhs);
3730
3731__returns `!(lhs < rhs)`.
3732
3733[endsect]
3734[endsect]
3735
3736
3737[section:time_point_cast Non-Member Function `time_point_cast(time_point)`]
3738
3739    template <class __ToDuration, class __Clock, class __Duration>
3740    constexpr
3741    __time_point<__Clock, ToDuration> __time_point_cast(const __time_point<__Clock, __Duration>& t);
3742
3743__requires This function will not participate in overload resolution unless `ToDuration` is an instantiation of __duration.
3744
3745__returns `__time_point<__Clock, ToDuration>(__duration_cast<ToDuration>(t.time_since_epoch()))`.
3746
3747[endsect]
3748
3749[endsect]
3750
3751[/=============================================]
3752[section:system_clocks_hpp Header `<boost/chrono/system_clocks.hpp>`]
3753[/=============================================]
3754
3755This file contains the standard clock classes. The types defined in this section satisfy the __TrivialClock requirements
3756
3757    namespace boost {
3758      namespace chrono {
3759
3760        // Clocks
3761        class __system_clock;
3762        class __steady_clock;
3763        class __high_resolution_clock;
3764
3765        template <class CharT>
3766        struct clock_string<system_clock, CharT>;
3767        template <class CharT>
3768        struct clock_string<steady_clock, CharT>;
3769
3770      }
3771    }
3772
3773
3774[section:system_clock Class `system_clock`]
3775
3776The __system_clock class provides a means of obtaining the current wall-clock time from the system-wide real-time clock. The current time can be obtained by calling `system_clock::now()`. Instances of `system_clock::time_point`  can be converted to and from time_t  with the `system_clock::to_time_t()`  and `system_clock::from_time_t()`  functions. If system clock is not steady, a subsequent call to `system_clock::now()`  may return an earlier time than a previous call (e.g. if the operating system clock is manually adjusted, or synchronized with an external clock).
3777
3778The current implementation of __system_clock is related an epoch (midnight UTC of January 1, 1970), but this is not in the contract. You need to use the static function static
3779
3780    std::time_t to_time_t(const time_point& t);
3781
3782which returns a `time_t` type that is based on midnight UTC of January 1, 1970.
3783
3784    class system_clock {
3785    public:
3786        typedef __see_bellow__          duration;
3787        typedef duration::rep                        rep;
3788        typedef duration::period                     period;
3789        typedef chrono::__time_point<system_clock>     time_point;
3790        static constexpr bool is_steady =            false;
3791
3792
3793        static time_point  now() noexcept;
3794        static time_point  now(system::error_code & ec);
3795
3796        // Map to C API
3797        static std::time_t to_time_t(const time_point& t) noexcept;
3798        static time_point  from_time_t(std::time_t t) noexcept;
3799    };
3800
3801__system_clock satisfy the __clock_req:
3802
3803* `system_clock::duration::min() < system_clock::duration::zero()` is `true`.
3804
3805* The nested `duration` typedef has a resolution that depends on the one provided by the platform.
3806
3807[section:to_time_t Static Member Function `to_time_t(time_point)`]
3808
3809    time_t to_time_t(const time_point& t) noexcept;
3810
3811__returns A `time_t` such that the `time_t` and `t` represent the same point in time, truncated to the coarser of the precisions among `time_t` and `time_point`.
3812
3813[endsect]
3814[section:from_time_t Static Member Function `from_time_t(time_t)`]
3815
3816    time_point from_time_t(time_t t) noexcept;
3817
3818__returns A __time_point such that the __time_point and `t` represent the same point in time, truncated to the coarser of the precisions among __time_point and `time_t`.
3819
3820[endsect]
3821[endsect]
3822
3823[section:BOOST_CHRONO_HAS_CLOCK_STEADY Macro `BOOST_CHRONO_HAS_CLOCK_STEADY`]
3824
3825Defined if the platform support steady clocks.
3826
3827[endsect]
3828
3829[section:steady_clock Class `steady_clock`]
3830
3831__steady_clock satisfy the __clock_req.
3832
3833__steady_clock class provides access to the system-wide steady clock. The current time can be obtained by calling `steady_clock::now()`. There is no fixed relationship between values returned by `steady_clock::now()` and wall-clock time.
3834
3835    #ifdef BOOST_HAS_CLOCK_STEADY
3836        class steady_clock {
3837        public:
3838            typedef __nanoseconds                          duration;
3839            typedef duration::rep                        rep;
3840            typedef duration::period                     period;
3841            typedef chrono::__time_point<steady_clock>     time_point;
3842            static constexpr bool is_steady =            true;
3843
3844            static time_point  now() noexcept;
3845            static time_point  now(system::error_code & ec);
3846        };
3847    #endif
3848
3849[endsect]
3850
3851[section:high_resolution_clock Class `high_resolution_clock`]
3852
3853__high_resolution_clock satisfy the __clock_req.
3854
3855    #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
3856      typedef __steady_clock high_resolution_clock;  // as permitted by [time.clock.hires]
3857    #else
3858      typedef __system_clock high_resolution_clock;  // as permitted by [time.clock.hires]
3859    #endif
3860
3861[endsect]
3862
3863[section:clock_string_system_clock `clock_string<system_clock>` Specialization]
3864
3865    template <class CharT>
3866    struct clock_string<system_clock, CharT>
3867    {
3868        static std::basic_string<CharT> name();
3869        static std::basic_string<CharT> since();
3870    };
3871
3872`clock_string<>::name()` returns "system_clock".
3873
3874`clock_string<>::since()` returns " since Jan 1, 1970"
3875
3876
3877[endsect]
3878
3879[section:clock_string_steady_clock `clock_string<steady_clock>` Specialization]
3880
3881    #ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
3882
3883    template <class CharT>
3884    struct clock_string<steady_clock, CharT>
3885    {
3886        static std::basic_string<CharT> name();
3887        static std::basic_string<CharT> since();
3888    };
3889    #endif
3890
3891`clock_string<>::name()` returns "steady_clock".
3892
3893`clock_string<>::since()` returns " since boot"
3894
3895[endsect]
3896
3897[endsect]
3898
3899[/==================================================================]
3900[section:clock_strings_hpp Header `<boost/chrono/clock_strings.hpp>`]
3901[/==================================================================]
3902
3903    namespace boost {
3904      namespace chrono {
3905
3906        template <class __Clock, class CharT>
3907        struct clock_string;
3908
3909      }
3910    }
3911
3912[section:clock_string Template Class `clock_string<>`]
3913
3914    template <class __Clock, class CharT>
3915    struct clock_string;
3916
3917This template must be specialized for specific clocks. The specialization must define the following functions
3918
3919        static std::basic_string<CharT> name();
3920        static std::basic_string<CharT> since();
3921
3922`clock_string<>::name()` return the clock name, which usually corresponds to the class name.
3923
3924`clock_string<>::since()` return the textual format of the clock epoch.
3925
3926
3927[endsect]
3928
3929[endsect] [/section:clock_strings_hpp Header `<boost/chrono/clock_strings.hpp>`]
3930
3931[/=============================================]
3932[section:chrono_typeof_hpp Header `<boost/chrono/typeof/boost/chrono/chrono.hpp>`]
3933[/=============================================]
3934
3935Register __duration`<>` and __time_point`<>` class templates to [*Boost.Typeof].
3936
3937[endsect]
3938[endsect]
3939
3940[section:io_v1 Chrono I/O V1]
3941[/==================================================================]
3942[section:chrono_io_hpp Header `<boost/chrono/chrono_io.hpp>`]
3943[/==================================================================]
3944
3945
3946
3947    namespace boost {
3948    namespace chrono {
3949
3950        template <class CharT>
3951        class duration_punct;
3952
3953        template <class CharT, class Traits>
3954            std::basic_ostream<CharT, Traits>&
3955            duration_short(std::basic_ostream<CharT, Traits>& os);
3956
3957        template <class CharT, class Traits>
3958            std::basic_ostream<CharT, Traits>&
3959            duration_long(std::basic_ostream<CharT, Traits>& os);
3960
3961        template <class CharT, class Traits, class Rep, class Period>
3962            std::basic_ostream<CharT, Traits>&
3963            operator<<(std::basic_ostream<CharT, Traits>& os, const duration<Rep, Period>& d);
3964
3965        template <class CharT, class Traits, class Rep, class Period>
3966            std::basic_istream<CharT, Traits>&
3967            operator>>(std::basic_istream<CharT, Traits>& is, duration<Rep, Period>& d)
3968
3969        template <class CharT, class Traits, class Clock, class Duration>
3970            std::basic_ostream<CharT, Traits>&
3971            operator<<(std::basic_ostream<CharT, Traits>& os,
3972                   const time_point<Clock, Duration>& tp);
3973
3974        template <class CharT, class Traits, class Clock, class Duration>
3975            std::basic_istream<CharT, Traits>&
3976            operator>>(std::basic_istream<CharT, Traits>& is,
3977                   time_point<Clock, Duration>& tp);
3978
3979    }
3980    }
3981
3982[section:duration_punct Template Class `duration_punct<>`]
3983
3984The __duration unit names can be customized through the facet: __duration_punct. __duration unit names come in two varieties: long and short. The default constructed __duration_punct provides names in the long format. These names are English descriptions. Other languages are supported by constructing a __duration_punct with the proper spellings for "hours", "minutes" and "seconds", and their abbreviations (for the short format).
3985
3986        template <class CharT>
3987        class duration_punct
3988            : public std::locale::facet
3989        {
3990        public:
3991            typedef std::basic_string<CharT> string_type;
3992            enum {use_long, use_short};
3993
3994            static std::locale::id id;
3995
3996            explicit duration_punct(int use = use_long);
3997
3998            duration_punct(int use,
3999                const string_type& long_seconds, const string_type& long_minutes,
4000                const string_type& long_hours, const string_type& short_seconds,
4001                const string_type& short_minutes, const string_type& short_hours);
4002
4003            duration_punct(int use, const duration_punct& d);
4004
4005            template <class Period> string_type short_name() const;
4006            template <class Period> string_type long_name() const;
4007            template <class Period> string_type name() const;
4008
4009            bool is_short_name() const;
4010            bool is_long_name() const;
4011        };
4012
4013[endsect]
4014
4015[section:manipulators I/O Manipulators]
4016
4017The short or long format can be easily chosen by streaming a `duration_short` or `duration_long` manipulator respectively.
4018
4019        template <class CharT, class Traits>
4020            std::basic_ostream<CharT, Traits>&
4021            duration_short(std::basic_ostream<CharT, Traits>& os);
4022
4023__effects Set the __duration_punct facet to stream __durations and __time_points as abbreviations.
4024
4025__returns the output stream
4026
4027        template <class CharT, class Traits>
4028            std::basic_ostream<CharT, Traits>&
4029            duration_long(std::basic_ostream<CharT, Traits>& os);
4030
4031
4032__effects Set the __duration_punct facet to stream durations and time_points as long text.
4033
4034__returns the output stream
4035
4036
4037[endsect]
4038
4039[section:streams I/O Streams Operations]
4040
4041Any __duration can be streamed out to a `basic_ostream`. The run-time value of the __duration is formatted according to the rules and current format settings for __duration`::rep`. This is followed by a single space and then the compile-time unit name of the __duration. This unit name is built on the string returned from `ratio_string<>` and the data used to construct the __duration_punct which was inserted into the stream's locale. If a __duration_punct has not been inserted into the stream's locale, a default constructed __duration_punct will be added to the stream's locale.
4042
4043A __time_point is formatted by outputting its internal __duration followed by a string that describes the __time_point`::clock` epoch. This string will vary for each distinct clock, and for each implementation of the supplied clocks.
4044
4045        template <class CharT, class Traits, class Rep, class Period>
4046            std::basic_ostream<CharT, Traits>&
4047            operator<<(std::basic_ostream<CharT, Traits>& os, const duration<Rep, Period>& d);
4048
4049__effects outputs the __duration as an abbreviated or long text format depending on the state of the __duration_punct facet.
4050
4051__returns the output stream
4052
4053        template <class CharT, class Traits, class Rep, class Period>
4054            std::basic_istream<CharT, Traits>&
4055            operator>>(std::basic_istream<CharT, Traits>& is, duration<Rep, Period>& d)
4056
4057__effects reads a __duration from the input stream. If a format error is found, the input stream state will be set to `failbit`.
4058
4059__returns the  input stream
4060
4061        template <class CharT, class Traits, class Clock, class Duration>
4062            std::basic_ostream<CharT, Traits>&
4063            operator<<(std::basic_ostream<CharT, Traits>& os,
4064                   const time_point<Clock, Duration>& tp);
4065
4066__effects outputs the __time_point as an abbreviated or long text format depending on the state of the __duration_punct facet.
4067
4068__returns the output stream
4069
4070
4071        template <class CharT, class Traits, class Clock, class Duration>
4072            std::basic_istream<CharT, Traits>&
4073            operator>>(std::basic_istream<CharT, Traits>& is,
4074                   time_point<Clock, Duration>& tp);
4075
4076__effects reads a __time_point from the input stream. If a format error is found, the input stream state will be set to `failbit`.
4077
4078__returns the input stream
4079
4080[endsect]
4081
4082
4083[endsect]
4084[endsect]
4085
4086[section:io Chrono I/O V2]
4087
4088[/==================================================================]
4089[section:chrono_io_hpp Header `<boost/chrono/chrono_io.hpp>`]
4090[/==================================================================]
4091
4092
4093This file includes the i/o of the two major components, duration and time_point.
4094
4095        #include <boost/chrono/io/duration_style.hpp>
4096        #include <boost/chrono/io/timezone.hpp>
4097        #include <boost/chrono/io/ios_base_state.hpp>
4098        #include <boost/chrono/io/duration_get.hpp>
4099        #include <boost/chrono/io/duration_put.hpp>
4100        #include <boost/chrono/io/duration_units.hpp>
4101        #include <boost/chrono/io/duration_io.hpp>
4102        #include <boost/chrono/io/time_point_get.hpp>
4103        #include <boost/chrono/io/time_point_put.hpp>
4104        #include <boost/chrono/io/time_point_units.hpp>
4105        #include <boost/chrono/io/time_point_io.hpp>
4106
4107
4108[endsect] [/section:chrono_io_hpp Header `<boost/chrono/chrono_io.hpp>`]
4109
4110[/==================================================================]
4111[section:duration_style_hpp Header `<boost/chrono/io/duration_style.hpp>`]
4112[/==================================================================]
4113
4114
4115    namespace boost {
4116      namespace chrono {
4117
4118        // typedefs
4119        enum class __duration_style {
4120          __prefix, __symbol
4121        };
4122      }
4123    }
4124
4125[section:duration_style Scoped enum `duration_style`]
4126
4127          enum class duration_style {
4128            prefix, symbol
4129          };
4130
4131__duration unit names come in two varieties: prefix and symbol.
4132
4133[endsect] [/section:duration_style Scoped enum `duration_style`]
4134
4135[endsect] [/section:duration_style_hpp Header `<boost/chrono/io/duration_style.hpp>`]
4136
4137[/==================================================================]
4138[section:timezone_hpp Header `<boost/chrono/io/timezone.hpp>`]
4139[/==================================================================]
4140
4141    namespace boost {
4142      namespace chrono {
4143
4144        struct __timezone
4145        {
4146          enum type {
4147            __utc, __local
4148          };
4149        };
4150      }
4151    }
4152
4153[section:timezone Scoped enum `timezone`]
4154
4155          enum class timezone {
4156            utc, local
4157          };
4158
4159[endsect] [/section:timezone Scoped enum `timezone`]
4160
4161
4162[endsect] [/section:timezone_hpp Header `<boost/chrono/io/timezone.hpp>`]
4163
4164
4165[/==================================================================]
4166[section:ios_state_hpp Header `<boost/chrono/io/ios_base_state.hpp>`]
4167[/==================================================================]
4168
4169    namespace boost {
4170      namespace chrono {
4171
4172        // setters and getters
4173        duration_style __get_duration_style(std::ios_base & ios);
4174        void __set_duration_style(std::ios_base& ios, duration_style style);
4175
4176        timezone __get_timezone(std::ios_base & ios);
4177        void __set_timezone(std::ios_base& ios, timezone tz);
4178
4179        template<typename CharT>
4180        std::basic_string<CharT> __get_time_fmt(std::ios_base & ios);
4181        template<typename CharT>
4182        void __set_time_fmt(std::ios_base& ios, std::basic_string<CharT> const& fmt);
4183
4184        // i/o state savers
4185        struct __duration_style_io_saver;
4186        template<typename CharT = char, typename Traits = std::char_traits<CharT> >
4187        struct __timezone_io_saver;
4188        template<typename CharT = char, typename Traits = std::char_traits<CharT> >
4189        struct __time_fmt_io_saver;
4190      }
4191    }
4192
4193[section:sag Setter and getters]
4194
4195[section:get_duration_style Non Member Function `get_duration_style(std::ios_base &)`]
4196
4197        duration_style get_duration_style(std::ios_base & ios);
4198
4199__returns The stream's __duration_style attribute associated to `ios`.
4200
4201[endsect]
4202
4203[section:set_duration_style Non Member Function `set_duration_style(std::ios_base &,duration_style)`]
4204
4205        void set_duration_style(std::ios_base& ios, duration_style style);
4206
4207__effects Set the stream's __duration_style attribute associated to `ios` with the `style` parameter.
4208
4209[endsect]
4210
4211[section:get_timezone Non Member Function `get_timezone(std::ios_base&)`]
4212
4213        timezone get_timezone(std::ios_base & ios);
4214
4215__returns The stream's __timezone attribute associated to `ios`.
4216
4217[endsect]
4218
4219[section:set_timezone Non Member Function `set_timezone(std::ios_base&,duration_style)`]
4220
4221        void set_timezone(std::ios_base& ios, timezone tz);
4222
4223__effects Set the stream's __timezone attribute associated to `ios` with the `tz` parameter.
4224
4225[endsect]
4226
4227[section:get_time_fmt Non Member Function `get_time_fmt(std::ios_base &)`]
4228
4229        template<typename CharT>
4230        std::basic_string<CharT> get_time_fmt(std::ios_base & ios);
4231
4232__returns The stream's time format attribute associated to `ios`.
4233
4234[endsect]
4235
4236[section:set_time_fmt Non Member Function `set_time_fmt(std::ios_base&, std::basic_string<CharT> const&)`]
4237
4238        template<typename CharT>
4239        void set_time_fmt(std::ios_base& ios, std::basic_string<CharT> const& fmt);
4240
4241__effects Set the stream's time format attribute associated to `ios` with the `fmt` parameter.
4242
4243The format is composed of zero or more directives.
4244Each directive is composed of one of the following:
4245
4246 * one or more white-space characters (as specified by isspace());
4247 * an ordinary character (neither '%' nor a white-space character);
4248 * or a conversion specification.
4249
4250Each conversion specification is composed of a '%' character followed by a conversion character which specifies the replacement required.
4251The application shall ensure that there is white-space or other non-alphanumeric characters between any two conversion specifications.
4252The following conversion specifications are supported:
4253
4254[table Format tags
4255    [[Format Specifier]        [Description ]  [Example]]
4256    [[`%%`]        [Replaced by `%`.]  [.]]
4257    [[`%a %A`]        [The day of the week, using the locale's weekday names; either the abbreviated or full name may be specified.]  ["Monday".]]
4258    [[`%b %B %h`]        [The month, using the locale's month names; either the abbreviated or full name may be specified.]  ["February".]]
4259    [[`%c`]        [Not supported.]  [.]]
4260    [[`%d %e`]        [The day of the month `[01,31]`; leading zeros are permitted but not required..]  [.]]
4261    [[`%D`]        [The date as `%m/%d/%y`.]  [.]]
4262    [[`%F`]        [The date as `%Y/%m/%d`.]  [.]]
4263    [[`%H`]        [The hour (24-hour clock) `[00,23]`; leading zeros are permitted but not required.]  [.]]
4264    [[`%I`]        [The hour (12-hour clock) `[01,12]`; leading zeros are permitted but not required.]  [.]]
4265    [[`%j`]        [The day number of the year `[001,366]`; leading zeros are permitted but not required.]  ["060" => Feb-29.]]
4266    [[`%m`]        [The month number `[01,12]`; leading zeros are permitted but not required..]  ["01" => January.]]
4267    [[`%M`]        [The minute `[00,59]`; leading zeros are permitted but not required.]  [.]]
4268    [[`%n %t`]        [Any white space..]  [.]]
4269    [[`%p`]        [Not supported.]  [.]]
4270    [[`%r`]        [Not supported.]  [.]]
4271    [[`%R`]        [The time as `%H:%M`.]  [.]]
4272    [[`%S`]        [The seconds `[00,60]`; leading zeros are permitted but not required.]  [.]]
4273    [[`%T`]        [The time as `%H:%M:%S`.]  [.]]
4274    [[`%U`]        [Not supported.]  [.]]
4275    [[`%w`]        [The weekday as a decimal number `[0,6]`, with 0 representing Sunday; leading zeros are permitted but not required..]  ["0" => Sunday.]]
4276    [[`%W`]        [Not supported.]  [.]]
4277    [[`%x`]        [The date, using the locale's date format..]  [.]]
4278    [[`%X`]        [Not supported.]  [.]]
4279    [[`%y`]        [Not supported.]  ["2005".]]
4280    [[`%Y`]        [The year, including the century (for example, 1988).]  [.]]
4281]
4282
4283
4284[endsect]
4285
4286[endsect]
4287[section:ioss I/O State Savers]
4288[section:duration_style_io_saver Template Class `duration_style_io_saver`]
4289
4290        // i/o state savers
4291
4292        struct duration_style_io_saver
4293        {
4294          typedef std::ios_base state_type; // the state type is ios_base
4295          typedef __duration_style aspect_type; // the aspect type is the __duration_style
4296
4297          explicit __duration_style_io_saver__c1(state_type &s);
4298          __duration_style_io_saver__c2(state_type &s, aspect_type new_value);
4299          __duration_style_io_saver__d();
4300          void __duration_style_io_saver__restore();
4301        };
4302
4303The `state_type` is a version of the IOStreams base class `std::ios_base`.
4304
4305[section:c1 Constructor `duration_style_io_saver(state_type&)`]
4306
4307This constructor takes a stream object and saves a reference to the stream and
4308the current value of a particular stream attribute.
4309
4310          explicit duration_style_io_saver(state_type &s);
4311
4312__effects Constructs a __duration_style_io_saver by storing `s`.
4313
4314[endsect]
4315
4316[section:c2 Constructor `duration_style_io_saver(state_type&, aspect_type)`]
4317
4318This constructor works like the previous one, and in addition
4319uses its second argument to change the stream's attribute to the new `aspect_type` value given.
4320
4321          explicit duration_style_io_saver(state_type &s, aspect_type new_value);
4322
4323__effects Constructs a __duration_style_io_saver by storing `s`. Sets the `state_type` `aspect_type` with the value `new_value`.
4324
4325[endsect]
4326
4327[section:d Destructor `~duration_style_io_saver()`]
4328
4329The destructor restores the stream's attribute to the saved value.
4330
4331          ~duration_style_io_saver();
4332
4333__effects As if __duration_style_io_saver__restore().
4334
4335[endsect]
4336[section:restore Member Function `restore()`]
4337
4338The restoration can be activated early (and often) with the restore member function.
4339
4340          void restore();
4341
4342__effects Restores the stream's __duration_style attribute to the saved value.
4343
4344[endsect]
4345
4346
4347[endsect]
4348[section:timezone_io_saver Template Class `timezone_io_saver<>`]
4349
4350
4351        template<typename CharT = char, typename Traits = std::char_traits<CharT> >
4352        struct __timezone_io_saver
4353        {
4354          typedef std::basic_ios<CharT, Traits> state_type;
4355          typedef __timezone aspect_type;
4356
4357          explicit __timezone_io_saver__c1(state_type &s);
4358          __timezone_io_saver__c2(state_type &s, aspect_type new_value);
4359          __timezone_io_saver__d();
4360          void timezone_io_saver__restore();
4361        };
4362
4363
4364The `state_type` is a version of the IOStreams base class template `std::basic_ios<CharT, Traits>`, where `CharT` is a character type and `Traits` is a character traits class. The user would usually place an actual input, output, or combined stream object for the state-type parameter, and not a base class object.
4365
4366[section:c1 Constructor `timezone_io_saver(state_type&)`]
4367
4368This constructor takes a stream object and saves a reference to the stream and the current value of a particular stream attribute.
4369
4370          explicit timezone_io_saver(state_type &s);
4371
4372__effects Constructs a __timezone_io_saver by storing `s`.
4373
4374[endsect]
4375
4376[section:c2 Constructor `timezone_io_saver(state_type&, aspect_type)`]
4377
4378This constructor works like the previous one, and
4379uses its second argument to change the stream's attribute to the new aspect_type value given.
4380
4381          explicit timezone_io_saver(state_type &s, aspect_type new_value);
4382
4383__effects Constructs a __timezone_io_saver by storing `s`. Sets the `state_type` `aspect_type` with the value `new_value`.
4384
4385
4386[endsect]
4387
4388[section:d Destructor `~timezone_io_saver()`]
4389
4390The destructor restores the stream's attribute to the saved value.
4391
4392          ~timezone_io_saver();
4393
4394__effects As if __timezone_io_saver__restore().
4395
4396[endsect]
4397[section:restore Member Function `restore()`]
4398
4399The restoration can be activated early (and often) with the restore member function.
4400
4401          void restore();
4402
4403__effects Restores the stream's __timezone attribute to the saved value.
4404
4405[endsect]
4406
4407
4408[endsect]
4409
4410[section:time_fmt_io_saver Template Class `time_fmt_io_saver<>`]
4411
4412        template<typename CharT = char, typename Traits = std::char_traits<CharT> >
4413        struct __time_fmt_io_saver
4414        {
4415          typedef std::basic_ios<CharT, Traits> state_type;
4416
4417          explicit __time_fmt_io_saver__c1(state_type &s);
4418          __time_fmt_io_saver__c2(state_type &s, basic_string<CharT> const& new_value);
4419          __time_fmt_io_saver__d();
4420          void __time_fmt_io_saver__restore();
4421        };
4422
4423
4424The `state_type` is a version of the IOStreams base class template `std::basic_ios<CharT, Traits>`, where `CharT` is a character type and `Traits` is a character traits class. The user would usually place an actual input, output, or combined stream object for the state-type parameter, and not a base class object.
4425
4426[section:c1 Constructor `time_fmt_io_saver(state_type&)`]
4427
4428This constructor takes a stream object and saves a reference to the stream and the current value of a particular stream attribute.
4429
4430          explicit time_fmt_io_saver(state_type &s);
4431
4432__effects Constructs a __time_fmt_io_saver by storing `s`.
4433
4434[endsect]
4435
4436[section:c2 Constructor `time_fmt_io_saver(state_type&, aspect_type)`]
4437
4438This constructor works like the previous one, and
4439uses its second argument to change the stream's attribute to the new aspect_type value given.
4440
4441          explicit time_fmt_io_saver(state_type &s, aspect_type new_value);
4442
4443__effects Constructs a __time_fmt_io_saver by storing `s`. Sets the `state_type` `aspect_type` with the value `new_value`.
4444
4445
4446[endsect]
4447
4448[section:d Destructor `~time_fmt_io_saver()`]
4449
4450The destructor restores the stream's attribute to the saved value.
4451
4452          ~time_fmt_io_saver();
4453
4454__effects As if __time_fmt_io_saver__restore().
4455
4456[endsect]
4457[section:restore Member Function `restore()`]
4458
4459The restoration can be activated early (and often) with the restore member function.
4460
4461          void restore();
4462
4463__effects Restores the stream's time format attribute to the saved value.
4464
4465[endsect]
4466
4467[endsect]
4468[endsect]
4469
4470[endsect] [/section:ios_state_hpp Header `<boost/chrono/io/ios_sate.hpp>`]
4471
4472[/==================================================================]
4473[section:duration_get_hpp Header `<boost/chrono/io/duration_get.hpp>`]
4474[/==================================================================]
4475
4476    namespace boost {
4477      namespace chrono {
4478
4479        template <class CharT, class InputIterator = std::istreambuf_iterator<CharT> >
4480        class __duration_get;
4481
4482      }
4483    }
4484
4485[section:duration_get Template Class `duration_get`]
4486
4487    template <class CharT, class InputIterator = std::istreambuf_iterator<CharT> >
4488    class duration_get: public std::locale::facet
4489    {
4490    public:
4491      typedef CharT char_type; // Type of character the facet is instantiated on
4492      typedef std::basic_string<CharT> string_type; // Type of character string passed to member functions.
4493      typedef InputIterator iter_type; // Type of iterator used to scan the character buffer.
4494
4495      explicit __duration_get_c(size_t refs = 0);
4496
4497      template <typename Rep, typename Period>
4498      iter_type __duration_get_get(
4499        iter_type s,
4500        iter_type end,
4501        std::ios_base& ios,
4502        std::ios_base::iostate& err,
4503        duration<Rep, Period>& d,
4504        const char_type* pattern,
4505        const char_type* pat_end
4506      ) const;
4507
4508      template <typename Rep, typename Period>
4509      iter_type __duration_get_get2(
4510        iter_type s,
4511        iter_type end,
4512        std::ios_base& ios,
4513        std::ios_base::iostate& err,
4514        duration<Rep, Period>& d
4515      ) const;
4516
4517      template <typename Rep>
4518      iter_type __duration_get_get_value(
4519        iter_type s,
4520        iter_type end,
4521        std::ios_base& ios,
4522        std::ios_base::iostate& err,
4523        Rep& r
4524      ) const;
4525
4526      iter_type __duration_get_get_unit(
4527        iter_type i,
4528        iter_type e,
4529        std::ios_base& is,
4530        std::ios_base::iostate& err,
4531        detail::rt_ratio &rt
4532      ) const
4533
4534      static std::locale::id id; // Unique identifier for this type of facet.
4535
4536      __duration_get_d()
4537      {
4538      }
4539
4540    };
4541
4542
4543The __duration_get facet extracts duration from a character string and stores the resulting value in a class
4544duration d argument. The facet parses the string using a specific format as a guide.
4545If the string does not fit the format, then the facet will indicate an error by setting the err argument to
4546iosbase::failbit.
4547In other words, user confirmation is required for reliable parsing of
4548user-entered durations, but machine-generated formats can be parsed
4549reliably. This allows parsers to be aggressive about interpreting user
4550variations on standard formats.
4551
4552[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4553[section:c Constructor `duration_get(size_t)`]
4554
4555      explicit duration_get(size_t refs);
4556
4557Constructs a __duration_get facet.
4558
4559__params
4560
4561* [param refs] references
4562
4563__effects Constructs a __duration_get facet.
4564If the `refs` argument is `0` then destruction of the object is
4565delegated to the locale, or locales, containing it. This allows
4566the user to ignore lifetime management issues. On the other had,
4567if `refs` is `1` then the object must be explicitly deleted;
4568`locale` will not do so. In this case, the object can be
4569maintained across the lifetime of multiple locales.
4570
4571[endsect]
4572[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4573[section:d Destructor `~duration_get()`]
4574
4575      ~duration_get();
4576
4577Destructs a __duration_get facet.
4578
4579[endsect]
4580[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4581[section:get Template Member Function `get(iter_type,iter_type,std::ios_base&,std::ios_base::iostate&,duration<Rep,Period>&,const char_type*, const char_type*) const`]
4582
4583      template <typename Rep, typename Period>
4584      iter_type get(iter_type s, iter_type end, std::ios_base& ios, std::ios_base::iostate& err,
4585          duration<Rep, Period> &d, const char_type *pattern, const char_type *pat_end) const;
4586
4587Extracts a duration from the range `[s,end)` following the pattern `[pattern,pat_end)`.
4588
4589__params
4590
4591* [param s] start input stream iterator
4592* [param end] end input stream iterator
4593* [param ios] a reference to a ios_base
4594* [param err] the ios_base state
4595* [param d] the duration
4596* [param pattern] begin of the formatting pattern
4597* [param pat_end] end of the formatting pattern
4598
4599__requires `[s, end) and [pattern, pat_end)` shall be valid ranges.
4600
4601__effects The function starts by evaluating `err = std::ios_base::goodbit`.
4602
4603Then it computes an intermediate representation based on `Rep` according to the following rules:
4604
4605* If `Rep` is a floating point type, the intermediate representation is `long double`.
4606* Else if `Rep` is a signed integral type, the intermediate representation is `long long`.
4607* Else if `Rep` is an unsigned integral type, the intermediate representation is unsigned long long.
4608* Else intermediate representation is `Rep`.
4609
4610Next the following local variable `r` of type intermediate representation and `rt` of type `rt_ratio` are default constructed.
4611
4612It then enters a loop, reading zero or more characters from `s` at
4613each iteration. Unless otherwise specified below, the loop
4614terminates when the first of the following conditions holds:
4615
4616* The expression `pattern == pat_end` evaluates to `true`.
4617* The expression `err == std::ios_base::goodbit` evaluates to false.
4618* The expression `s == end` evaluates to `true`, in which case the
4619function evaluates `err = std::ios_base::eofbit | std::ios_base::failbit`.
4620* The next element of pattern is equal to `'%'`, followed by a conversion
4621specifier character, format.
4622If the number of elements in the range `[pattern,pat_end)` is not
4623sufficient to unambiguously determine whether the conversion
4624specification is complete and valid, the function evaluates
4625`err = std::ios_base::failbit`. Otherwise, the function evaluates
4626`s = get_value(s, end, ios, err, r)` when the conversion specification is 'v' and
4627`s = get_value(s, end, ios, err, rt)` when the conversion specification is 'u'.
4628If `err == std::ios_base::goodbit` holds after
4629the evaluation of the expression, the function increments pattern to
4630point just past the end of the conversion specification and continues
4631looping.
4632* The expression `isspace(*pattern, ios.getloc())` evaluates to `true`, in
4633which case the function first increments pattern until
4634`pattern == pat_end || !isspace(*pattern, ios.getloc())` evaluates to `true`,
4635then advances `s` until `s == end || !isspace(*s, ios.getloc())` is `true`,
4636and finally resumes looping.
4637* The next character read from `s` matches the element pointed to by
4638pattern in a case-insensitive comparison, in which case the function
4639evaluates `++pattern, ++s` and continues looping.
4640Otherwise, the function evaluates `err = std::ios_base::failbit`.
4641
4642If a duration representation value and a unit specifier have successfully been parsed, compute
4643`(rt.num/rt.den)/(Period::num/Period::den)` reduced to lowest terms.
4644If this ratio can not be stored without overflow, evaluates `err = std::ios_base::failbit`.
4645Otherwise store the result of this division in `num` and `den`.
4646
4647If the division did not result in overflow, then compute `r * num / den` in such a way as to avoid intermediate overflow.
4648If `r` has integral type and this computation would not be exact, evaluates `err = std::ios_base::failbit`.
4649If the result of the computation would overflow `Rep`, evaluates `err = std::ios_base::failbit`.
4650Otherwise the result of `r * num / den` is used to construct a `duration<Rep, Period>` which is assigned to `d`.
4651
4652__returns `s`, an iterator pointing just beyond the last character that can be determined to be part of a valid duration.
4653
4654[endsect]
4655[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4656[section:get2 Template Member Function `get(iter_type,iter_type,std::ios_base&,std::ios_base::iostate&,duration<Rep,Period>&) const`]
4657
4658      template <typename Rep, typename Period>
4659      iter_type get(
4660        iter_type s,
4661        iter_type end,
4662        std::ios_base& ios,
4663        std::ios_base::iostate& err,
4664        duration<Rep, Period>& d
4665      ) const;
4666
4667Extracts a duration from the range `[s,end)` following the default pattern.
4668
4669__params
4670
4671* [param s] start input stream iterator
4672* [param end] end input stream iterator
4673* [param ios] a reference to a ios_base
4674* [param err] the ios_base state
4675* [param d] the duration
4676
4677
4678__effects
4679Stores the duration pattern from the __duration_unit facet associated to 'ios` in let say `str`. Last as if
4680
4681  return get(s, end, ios, err, ios, d, str.data(), str.data() + str.size());
4682
4683__returns `s`, an iterator pointing just beyond the last character that can be determined to be part of a valid duration.
4684
4685
4686[endsect]
4687[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4688[section:get_value Template Member Function `get_value(iter_type,iter_type,std::ios_base&,std::ios_base::iostate&,Rep&) const`]
4689
4690      template <typename Rep>
4691      iter_type get_value(iter_type s, iter_type end, std::ios_base& ios, std::ios_base::iostate& err, Rep& r) const;
4692
4693Extracts a duration representation from the range `[s,end)`.
4694
4695__params
4696
4697* [param s] start input stream iterator
4698* [param end] end input stream iterator
4699* [param ios] a reference to a ios_base
4700* [param err] the ios_base state
4701* [param r] a reference to the duration representation
4702
4703__effects As if
4704
4705  return std::use_facet<std::num_get<char_type, iter_type>>(ios.getloc()).get(s, end, ios, err, r);
4706
4707__returns `s`, an iterator pointing just beyond the last character that can be determined to be part of a valid `Rep` value.
4708
4709[endsect]
4710[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4711[section:get_unit  Member Function `get_unit(iter_type,iter_type,std::ios_base&,std::ios_base::iostate&,rt_ratio&) const`]
4712
4713      iter_type get_unit(iter_type i, iter_type e, std::ios_base& is, std::ios_base::iostate& err, detail::rt_ratio &rt) const;
4714
4715Extracts a duration unit from the range `[s,end)`.
4716
4717__params
4718
4719* [param s] start input stream iterator
4720* [param end] end input stream iterator
4721* [param ios] a reference to a ios_base
4722* [param err] the ios_base state
4723* [param rt] a reference to the duration run-time ratio.
4724
4725__effects
4726
4727* If the first character is `'['`, an attempt is made to consume a pattern of the form
4728`"[N/D]"` where `N` and `D` have type `unsigned long long`.
4729  * If successful, rt records the values of `N` and `D`, otherwise evaluates `err = std::ios_base::failbit` and return `i`.
4730  * Return the parse the longest string possible matching one of the durations units that can follow the pattern `"[N/D]"`, as if
4731
4732   return do_get_n_d_prefix_unit(facet, i, e, is, err);
4733
4734* Otherwise the next character is not `'['`. Return the parse the longest string possible matching one of the
4735durations units, as if
4736
4737   return do_get_prefix_unit(facet, i, e, is, err, rt);
4738
4739__returns `i`, an iterator pointing just beyond the last character that can be determined to be part of a valid duration unit.
4740
4741[endsect]
4742[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4743[section:do_get_n_d_prefix_unit Protected Member Function `do_get_n_d_prefix_unit(duration_units<CharT> const&,iter_type,iter_type,std::ios_base&,std::ios_base::iostate&) const`]
4744
4745      virtual iter_type do_get_n_d_prefix_unit(
4746        duration_units<CharT> const &facet,
4747        iter_type i,
4748        iter_type e,
4749        std::ios_base&,
4750        std::ios_base::iostate& err
4751      ) const;
4752
4753Extracts the run-time ratio associated to the duration when it is given in [N/D] form.
4754
4755This is an extension point of this facet so that we can take in account other periods that can have a useful
4756translation in other contexts, as e.g. days and weeks.
4757
4758__params
4759
4760* [param s] start input stream iterator
4761* [param end] end input stream iterator
4762* [param ios] a reference to a ios_base
4763* [param err] the ios_base state
4764* [param rt] a reference to the duration run-time ratio.
4765
4766
4767__effects Scan `s` for the longest of all the plural forms associated with the duration units.
4768If successful, sets the matched ratio in `rt`. Otherwise evaluates `err = std::ios_base::failbit`.
4769
4770__returns `s`, an iterator pointing just beyond the last character that can be determined to be part of a valid name.
4771
4772[endsect]
4773[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4774[section:do_get_prefix_unit  Protected Member Function `do_get_prefix_unit(duration_units<CharT> const&,iter_type,iter_type,std::ios_base&,std::ios_base::iostate&,detail::rt_ratio&) const`]
4775
4776      virtual iter_type do_get_prefix_unit(
4777        duration_units<CharT> const &facet,
4778        iter_type i,
4779        iter_type e,
4780        std::ios_base&,
4781        std::ios_base::iostate& err,
4782        detail::rt_ratio &rt
4783      ) const;
4784
4785Extracts the run-time ratio associated to the duration when it is given in prefix form.
4786
4787This is an extension point of this facet so that we can take in account other periods that can have a useful
4788translation in other contexts, as e.g. days and weeks.
4789
4790__params
4791
4792* [param s] start input stream iterator
4793* [param end] end input stream iterator
4794* [param ios] a reference to a ios_base
4795* [param err] the ios_base state
4796* [param rt] a reference to the duration run-time ratio.
4797
4798
4799__effects Scan `s` for the longest of all the plural forms associated with the duration units.
4800If successful, sets the matched ratio in `rt`. Otherwise evaluates `err = std::ios_base::failbit`.
4801
4802__returns `s`, an iterator pointing just beyond the last character that can be determined to be part of a valid name.
4803
4804[endsect]
4805[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4806
4807[endsect]
4808
4809[endsect] [/section:duration_get_hpp]
4810
4811[/==================================================================]
4812[section:duration_put_hpp Header `<boost/chrono/io/duration_put.hpp>`]
4813[/==================================================================]
4814
4815    namespace boost {
4816      namespace chrono {
4817
4818        template <class CharT, class OutputIterator = std::ostreambuf_iterator<CharT> >
4819        class __duration_put;
4820
4821      }
4822    }
4823
4824[section:duration_put Template Class `duration_put`]
4825
4826    template <class CharT, class OutputIterator = std::ostreambuf_iterator<CharT> >
4827    class duration_put: public std::locale::facet
4828    {
4829    public:
4830      typedef CharT char_type; // Type of character the facet is instantiated on.
4831      typedef std::basic_string<CharT> string_type; // Type of character string passed to member functions.
4832      typedef OutputIterator iter_type; // Type of iterator used to write in the character buffer.
4833
4834      explicit __duration_put_c(size_t refs = 0);
4835
4836      template <typename Rep, typename Period>
4837      iter_type __duration_put_put(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d, const CharT* pattern,
4838          const CharT* pat_end) const;
4839
4840      template <typename Rep, typename Period>
4841      iter_type __duration_put_put2(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const;
4842
4843      template <typename Rep, typename Period>
4844      iter_type __duration_put_put_value(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const;
4845
4846      template <typename Rep, typename Period>
4847      iter_type __duration_put_put_unit(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const;
4848
4849
4850      static std::locale::id id; // Unique identifier for this type of facet.
4851
4852      __duration_put_d();
4853    };
4854
4855[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4856[section:c Constructor `duration_put(size_t)`]
4857
4858      explicit duration_put(size_t refs);
4859
4860Constructs a __duration_put facet.
4861
4862__params
4863
4864* [param refs] references
4865
4866__effects Constructs a __duration_put facet.
4867If the `refs` argument is `0` then destruction of the object is
4868delegated to the locale, or locales, containing it. This allows
4869the user to ignore lifetime management issues. On the other had,
4870if `refs` is `1` then the object must be explicitly deleted;
4871`locale` will not do so. In this case, the object can be
4872maintained across the lifetime of multiple locales.
4873
4874[endsect]
4875[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4876[section:d Destructor `~duration_put()`]
4877
4878      ~duration_put();
4879
4880Destructs a __duration_put facet.
4881
4882[endsect]
4883[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4884[section:put  Member Function `put(iter_type,std::ios_base&,char_type,duration<Rep,Period> const&, const CharT*,const CharT*)`]
4885
4886      template <typename Rep, typename Period>
4887      iter_type put(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d, const CharT* pattern,
4888          const CharT* pat_end) const;
4889
4890__params
4891
4892* [param s] an output stream iterator
4893* [param ios] a reference to a ios_base
4894* [param d] the duration
4895* [param pattern] begin of the formatting pattern
4896* [param pat_end] end of the formatting pattern
4897
4898__effects Steps through the sequence from `pattern` to `pat_end`,
4899identifying characters that are part of a pattern sequence. Each character
4900that is not part of a pattern sequence is written to `s` immediately, and
4901each pattern sequence, as it is identified, results in a call to `put_value` or `put_unit`;
4902thus, pattern elements and other characters are interleaved in the output
4903in the order in which they appear in the pattern. Pattern sequences are
4904identified by converting each character `c` to a `char` value as if by
4905`ct.narrow(c,0)`, where `ct` is a reference to `ctype<charT>` obtained from
4906`ios.getloc()`. The first character of each sequence is equal to `'%'`,
4907followed by a pattern specifier character specifier, which can be `'v'` for
4908the duration value or `'u'` for the duration unit. .
4909For each valid pattern sequence identified, calls
4910`put_value(s, ios, d)` or `put_unit(s, ios, d)`.
4911
4912__returns An iterator pointing immediately after the last character produced.
4913
4914
4915[endsect]
4916[section:put2  Member Function `put(iter_type,std::ios_base&,char_type fill, duration<Rep, Period> const&)`]
4917
4918      template <typename Rep, typename Period>
4919      iter_type put(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const;
4920
4921__params
4922
4923* [param s] an output stream iterator
4924* [param ios] a reference to a ios_base
4925* [param d] the duration
4926
4927Retrieves Stores the duration pattern from the __duration_unit facet in let say `str`. Last as if
4928
4929  return put(s, ios, d, str.data(), str.data() + str.size());
4930
4931__returns An iterator pointing immediately after the last character produced.
4932
4933[endsect]
4934[section:put_value  Member Function `put_value(iter_type, std::ios_base&, char_type, duration<Rep,Period> const&)`]
4935
4936      template <typename Rep, typename Period>
4937      iter_type put_value(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const;
4938
4939__params
4940
4941* [param s] an output stream iterator
4942* [param ios] a reference to a ios_base
4943* [param d] the duration
4944
4945__effects As if std::use_facet<std::num_put<CharT, iter_type> >(ios.getloc()).put(s, ios, ' ', static_cast<long int> (d.count())).
4946
4947__returns An iterator pointing immediately after the last character produced.
4948
4949[endsect]
4950[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4951[section:put_unit  Member Function `put_unit(iter_type,std::ios_base&,char_type,duration<Rep, Period> const&)`]
4952
4953      template <typename Rep, typename Period>
4954      iter_type put_unit(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const;
4955
4956__params
4957
4958* [param s] an output stream iterator
4959* [param ios] a reference to a ios_base
4960* [param fill] the fill character
4961* [param d] the duration
4962
4963__effects Let `facet` be the `duration_units<CharT>` facet associated to `ios`. If the associated unit is named, as if
4964
4965          string_type str = facet.get_unit(get_duration_style(ios), d);
4966          s=std::copy(str.begin(), str.end(), s);
4967
4968Otherwise, format the unit as `"[Period::num/Period::den]"` followed by the unit associated to [N/D] obtained using `facet.get_n_d_unit(get_duration_style(ios), d)`.
4969
4970__returns s,  iterator pointing immediately after the last character produced.
4971
4972[endsect]
4973[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
4974[endsect]
4975
4976[endsect] [/section:duration_put_hpp]
4977
4978[/==================================================================]
4979[section:duration_units_hpp Header `<boost/chrono/io/duration_units.hpp>`]
4980[/==================================================================]
4981
4982    namespace boost {
4983      namespace chrono {
4984        class rt_ratio;
4985        template <typename CharT = char>
4986        class duration_units;
4987
4988      }
4989    }
4990
4991
4992[section:rt_ratio Class `rt_ratio`]
4993
4994    class rt_ratio
4995    {
4996    public:
4997      template <typename Period>
4998      rt_ratio(Period const&) :
4999        num(Period::type::num), den(Period::type::den)
5000      {
5001      }
5002
5003      rt_ratio(intmax_t n = 0, intmax_t d = 1) :
5004        num(n), den(d)
5005      {
5006      }
5007
5008      intmax_t num;
5009      intmax_t den;
5010    };
5011
5012[endsect]
5013[section:duration_units Template Class `duration_units`]
5014
5015    template <typename CharT = char>
5016    class duration_units: public std::locale::facet
5017    {
5018    public:
5019      typedef CharT char_type; // Type of character the facet is instantiated on.
5020      typedef std::basic_string<CharT> string_type; // Type of character string passed to member functions.
5021      static std::locale::id id; // Unique identifier for this type of facet.
5022
5023      explicit __duration_units_c(size_t refs = 0);
5024      virtual const string_type* __duration_units_get_n_d_valid_units_start() const =0;
5025      virtual const string_type* __duration_units_get_n_d_valid_units_end() const=0;
5026      virtual const string_type* __duration_units_get_valid_units_start() const=0;
5027      virtual const string_type* __duration_units_get_valid_units_end() const=0;
5028      virtual bool __duration_units_match_n_d_valid_unit(const string_type* k) const = 0;
5029      virtual bool __duration_units_match_valid_unit(const string_type* k, rt_ratio& rt) const = 0;
5030      virtual string_type __duration_units_get_pattern() const=0;
5031      template <typename Rep, typename Period>
5032      string_type __duration_units_get_unit(duration_style style, duration<Rep, Period> const& d) const;
5033      template <typename Rep, typename Period>
5034      string_type __duration_units_get_n_d_unit(duration_style style, duration<Rep, Period> const& d) const;
5035      template <typename Period>
5036      bool __duration_units_is_named_unit() const;
5037
5038    protected:
5039      virtual __duration_units_d();
5040      virtual string_type __duration_units_do_get_n_d_unit(duration_style style, rt_ratio rt, intmax_t v) const = 0;
5041      virtual string_type __duration_units_do_get_unit(duration_style style,rt_ratio rt, intmax_t v) const = 0;
5042      virtual bool __duration_units_do_is_named_unit(rt_ratio rt) const =0;
5043    };
5044
5045__duration_units facet gives useful information about the duration units,
5046as the number of plural forms, the plural form associated to a duration,
5047the text associated to a plural form and a duration's period,
5048
5049[section:c Constructor `duration_units()`]
5050
5051      explicit duration_units(size_t refs = 0);
5052
5053Construct a __duration_units facet.
5054
5055__params
5056
5057* [param refs] references
5058
5059__effects Construct a __duration_units facet.
5060If the `refs` argument is `0` then destruction of the object is
5061delegated to the locale, or locales, containing it. This allows
5062the user to ignore lifetime management issues. On the other had,
5063if `refs` is `1` then the object must be explicitly deleted;
5064the locale will not do so. In this case, the object can be
5065maintained across the lifetime of multiple locales.
5066
5067[endsect]
5068[section:d Destructor `~duration_units()`]
5069
5070      virtual ~duration_units();
5071
5072__effects Destroys the facet.
5073
5074[endsect]
5075[section:get_n_d_valid_units_start Member Function `get_n_d_valid_units_start()`]
5076
5077      virtual const string_type* get_n_d_valid_units_start() const =0;
5078
5079__returns pointer to the start of valid [N/D] units.
5080
5081
5082[endsect]
5083[section:get_n_d_valid_units_end Member Function `get_n_d_valid_units_end()`]
5084
5085      virtual const string_type* get_n_d_valid_units_end() const=0;
5086
5087__returns pointer to the end of valid [N/D] units.
5088
5089[endsect]
5090[section:get_valid_units_start Member Function `get_valid_units_start()`]
5091
5092      virtual const string_type* get_valid_units_start() const=0;
5093
5094__returns pointer to the start of valid units, symbol or prefix with its different plural forms.
5095
5096[endsect]
5097[section:get_valid_units_end Member Function `get_valid_units_end()`]
5098
5099      virtual const string_type* get_valid_units_end() const=0;
5100
5101__returns pointer to the end of valid units.
5102
5103[endsect]
5104[section:match_n_d_valid_unit Member Function `match_n_d_valid_unit(const string_type*)`]
5105
5106      virtual bool match_n_d_valid_unit(const string_type* k) const = 0;
5107
5108__params
5109
5110* [param k] the found pointer to the [N/D] unit.
5111
5112__returns `true` if `k` matches a valid unit.
5113
5114[endsect]
5115[section:match_valid_unit Member Function `match_valid_unit(const string_type*,rt_ratio&)`]
5116
5117      virtual bool match_valid_unit(const string_type* k, rt_ratio& rt) const = 0;
5118
5119__params
5120
5121* [param k] the found pointer to the unit.
5122
5123__effects `rt` is set to the valid Period when the `k` matches a valid unit.
5124__returns `true` if `k` matches a valid unit.
5125
5126[endsect]
5127[section:get_pattern Member Function `get_pattern()`]
5128
5129      virtual string_type get_pattern() const=0;
5130
5131__returns the pattern to be used by default.
5132
5133[endsect]
5134[section:get_unit Template Member Function `get_unit(duration_style,duration<Rep,Period> const&)`]
5135
5136      template <typename Rep, typename Period>
5137      string_type get_unit(duration_style style, duration<Rep, Period> const& d) const;
5138
5139
5140__returns `get_unit(style, d.count(), rt_ratio(Period()))`, the unit associated to this duration.
5141
5142[endsect]
5143
5144[section:get_n_d_unit Template Member Function `get_n_d_unit(duration_style,duration<Rep,Period> const&)`]
5145
5146      template <typename Rep, typename Period>
5147      string_type get_n_d_unit(duration_style style, duration<Rep, Period> const& d) const;
5148
5149__returns get_n_d_unit(style, d.count(), rt_ratio(Period())), i.e. the [N/D] suffix unit associated to this duration.
5150
5151[endsect]
5152
5153[section:is_named_unit Template Member Function `is_named_unit()`]
5154
5155      template <typename Period>
5156      bool is_named_unit() const;
5157
5158__returns `do_is_named_unit(rt_ratio(Period()))`, true if the unit associated to the given Period is named, false otherwise.
5159
5160[endsect]
5161
5162[section:do_get_n_d_unit Protected Member Function `do_get_n_d_unit(duration_style,rt_ratio,intmax_t)`]
5163
5164      virtual string_type do_get_n_d_unit(duration_style style, rt_ratio rt, intmax_t v) const = 0;
5165
5166__returns the [N/D] suffix unit associated to this duration.
5167
5168[endsect]
5169
5170[section:do_get_unit Protected Member Function `do_get_unit(duration_style,rt_ratio,intmax_t)`]
5171
5172      virtual string_type do_get_unit(duration_style style,rt_ratio rt, intmax_t v) const = 0;
5173
5174__returns the unit associated to this duration.
5175
5176[endsect]
5177
5178[section:do_is_named_unit Protected Member Function `do_is_named_unit(rt_ratio)`]
5179
5180      virtual bool do_is_named_unit(rt_ratio rt) const =0;
5181
5182__returns true if the unit associated to the given Period is named, false otherwise.
5183
5184[endsect]
5185
5186[endsect] [/section:duration_units]
5187
5188[section:duration_units_default Template Class `duration_units_default`]
5189
5190    template <typename CharT = char>
5191    class duration_units_default: public duration_units<CharT>
5192    {
5193    protected:
5194      static const std::size_t pfs_ = 2; // The default English facet has two plural forms.
5195
5196    public:
5197      typedef CharT char_type;
5198      typedef std::basic_string<CharT> string_type;
5199
5200      explicit duration_units_default(size_t refs = 0);
5201      ~duration_units_default();
5202
5203      bool match_n_d_valid_unit(const string_type* k) const;
5204      bool match_valid_unit(const string_type* k, rt_ratio& rt) const;
5205      const string_type* get_n_d_valid_units_start()const;
5206      const string_type* get_n_d_valid_units_end()const;
5207      string_type* get_valid_units_start() const;
5208      string_type* get_valid_units_end() const;
5209      string_type get_pattern() const;
5210    protected:
5211      bool do_is_named_unit(rt_ratio rt) const;
5212      string_type do_get_n_d_unit(duration_style style, rt_ratio, intmax_t v) const;
5213      string_type do_get_unit(duration_style style, rt_ratio rt, intmax_t v) const;
5214
5215      virtual std::size_t do_get_plural_forms() const;
5216      virtual std::size_t do_get_plural_form(int_least64_t value) const;
5217
5218      virtual string_type do_get_unit(duration_style style, ratio<1> u, std::size_t pf) const;
5219      virtual string_type do_get_unit(duration_style style, ratio<60> u, std::size_t pf) const;
5220      virtual string_type do_get_unit(duration_style style, ratio<3600> u, std::size_t pf) const;
5221      virtual string_type do_get_unit(duration_style style, atto u, std::size_t pf) const;
5222      virtual string_type do_get_unit(duration_style style, femto u, std::size_t pf) const;
5223      virtual string_type do_get_unit(duration_style style, pico u, std::size_t pf) const;
5224      virtual string_type do_get_unit(duration_style style, nano u, std::size_t pf) const;
5225      virtual string_type do_get_unit(duration_style style, micro u, std::size_t pf) const;
5226      virtual string_type do_get_unit(duration_style style, milli u, std::size_t pf) const;
5227      virtual string_type do_get_unit(duration_style style, centi u, std::size_t pf) const;
5228      virtual string_type do_get_unit(duration_style style, deci u, std::size_t pf) const;
5229      virtual string_type do_get_unit(duration_style style, deca u, std::size_t pf) const;
5230      virtual string_type do_get_unit(duration_style style, hecto u, std::size_t pf) const;
5231      virtual string_type do_get_unit(duration_style style, kilo u, std::size_t pf) const;
5232      virtual string_type do_get_unit(duration_style style, mega u, std::size_t pf) const;
5233      virtual string_type do_get_unit(duration_style style, giga u, std::size_t pf) const;
5234      virtual string_type do_get_unit(duration_style style, tera u, std::size_t pf) const;
5235      virtual string_type do_get_unit(duration_style style, peta u, std::size_t pf) const;
5236      virtual string_type do_get_unit(duration_style style, exa u, std::size_t pf) const;
5237
5238      virtual string_type do_get_ratio_prefix(duration_style style, atto u) const;
5239      virtual string_type do_get_ratio_prefix(duration_style style, femto u) const;
5240      virtual string_type do_get_ratio_prefix(duration_style style, pico u) const;
5241      virtual string_type do_get_ratio_prefix(duration_style style, nano u) const;
5242      virtual string_type do_get_ratio_prefix(duration_style style, micro u) const;
5243      virtual string_type do_get_ratio_prefix(duration_style style, milli u) const;
5244      virtual string_type do_get_ratio_prefix(duration_style style, centi u) const;
5245      virtual string_type do_get_ratio_prefix(duration_style style, deci u) const;
5246      virtual string_type do_get_ratio_prefix(duration_style style, deca u) const;
5247      virtual string_type do_get_ratio_prefix(duration_style style, hecto u) const;
5248      virtual string_type do_get_ratio_prefix(duration_style style, kilo u) const;
5249      virtual string_type do_get_ratio_prefix(duration_style style, mega u) const;
5250      virtual string_type do_get_ratio_prefix(duration_style style, giga u) const;
5251      virtual string_type do_get_ratio_prefix(duration_style style, tera u) const;
5252      virtual string_type do_get_ratio_prefix(duration_style style, peta u) const;
5253      virtual string_type do_get_ratio_prefix(duration_style style, exa u) const;
5254    };
5255
5256This class is used to define the strings for the default English.
5257This facet names the units associated to the following periods:
5258
5259* __atto,
5260* __femto,
5261* __pico,
5262* __nano,
5263* __micro,
5264* __milli,
5265* __centi,
5266* __deci,
5267* ratio<1>,
5268* __deca,
5269* __hecto,
5270* __kilo,
5271* __mega,
5272* __giga,
5273* __tera,
5274* __peta,
5275* __exa,
5276* ratio<60> and
5277* ratio<3600>.
5278
5279
5280[section:c Constructor `duration_units_default()`]
5281
5282      explicit duration_units_default(size_t refs = 0);
5283
5284Construct a duration_units_default facet.
5285
5286__params
5287
5288* [param refs] references
5289
5290__effects Construct a duration_units_default facet.
5291If the `refs` argument is `0` then destruction of the object is
5292delegated to the locale, or locales, containing it. This allows
5293the user to ignore lifetime management issues. On the other had,
5294if `refs` is `1` then the object must be explicitly deleted;
5295the locale will not do so. In this case, the object can be
5296maintained across the lifetime of multiple locales.
5297
5298[endsect]
5299[section:d Destructor `~duration_units_default()`]
5300
5301      virtual ~duration_units_default();
5302
5303__effects Destroys the facet.
5304
5305[endsect]
5306[section:get_n_d_valid_units_start Member Function `get_n_d_valid_units_start()`]
5307
5308      virtual const string_type* get_n_d_valid_units_start() const;
5309
5310__returns pointer to the start of valid [N/D] units.
5311
5312
5313[endsect]
5314[section:get_n_d_valid_units_end Member Function `get_n_d_valid_units_end()`]
5315
5316      virtual const string_type* get_n_d_valid_units_end() const;
5317
5318__returns pointer to the end of valid [N/D] units.
5319
5320[endsect]
5321[section:get_valid_units_start Member Function `get_valid_units_start()`]
5322
5323      virtual const string_type* get_valid_units_start() const;
5324
5325__returns pointer to the start of valid units, symbol or prefix with its different plural forms.
5326
5327[endsect]
5328[section:get_valid_units_end Member Function `get_valid_units_end()`]
5329
5330      virtual const string_type* get_valid_units_end() const;
5331
5332__returns pointer to the end of valid units.
5333
5334[endsect]
5335[section:match_n_d_valid_unit Member Function `match_n_d_valid_unit(const string_type*)`]
5336
5337      virtual bool match_n_d_valid_unit(const string_type* k) const;
5338
5339__params
5340
5341* [param k] the found pointer to the [N/D] unit.
5342
5343__returns `true` if `k` matches a valid unit.
5344
5345[endsect]
5346[section:match_valid_unit Member Function `match_valid_unit(const string_type*,rt_ratio&)`]
5347
5348      virtual bool match_valid_unit(const string_type* k, rt_ratio& rt) const;
5349
5350__params
5351
5352* [param k] the found pointer to the unit.
5353
5354__effects `rt` is set to the valid Period when the `k` matches a valid unit.
5355__returns `true` if `k` matches a valid unit.
5356
5357[endsect]
5358[section:get_pattern Member Function `get_pattern()`]
5359
5360      virtual string_type get_pattern() const;
5361
5362__returns the pattern to be used by default.
5363
5364[endsect]
5365
5366[section:do_get_n_d_unit Protected Member Function `do_get_n_d_unit(duration_style,rt_ratio,intmax_t)`]
5367
5368      virtual string_type do_get_n_d_unit(duration_style style, rt_ratio rt, intmax_t v) const;
5369
5370__returns the [N/D] suffix unit associated to this duration.
5371
5372[endsect]
5373
5374[section:do_get_unit Protected Member Function `do_get_unit(duration_style,rt_ratio,intmax_t)`]
5375
5376      virtual string_type do_get_unit(duration_style style,rt_ratio rt, intmax_t v) const;
5377
5378__returns the unit associated to this duration.
5379
5380[endsect]
5381
5382[section:do_is_named_unit Protected Member Function `do_is_named_unit(rt_ratio)`]
5383
5384      virtual bool do_is_named_unit(rt_ratio rt) const;
5385
5386__returns true if the unit associated to the given Period is named, false otherwise.
5387
5388[endsect]
5389
5390[section:do_get_plural_forms Protected Member Function `do_get_plural_forms()`]
5391
5392      virtual std::size_t do_get_plural_forms() const;
5393
5394__returns the number of associated plural forms this facet manages.
5395
5396[endsect]
5397
5398[section:do_get_plural_form Protected Member Function `do_get_plural_form(int_least64_t)`]
5399
5400      virtual std::size_t do_get_plural_form(int_least64_t value) const;
5401
5402Gets the associated plural form.
5403
5404__params
5405
5406[param value] the duration representation
5407
5408__returns the plural form associated to the `value` parameter. In English there are 2 plural forms
5409
5410* 0 singular (-1 or 1)
5411* 1 plural for all others
5412
5413[endsect]
5414
5415[section:do_get_unit_seconds Protected Member Function `do_get_unit(duration_style,ratio<1>,std::size_t)`]
5416
5417      virtual string_type do_get_unit(duration_style style, ratio<1> u, std::size_t pf) const;
5418
5419__params
5420
5421* [param style] the duration style.
5422* [param period] the period associated to the duration hours.
5423* [param pf] the requested plural form.
5424
5425__returns if style is symbol returns "s", otherwise if pf is 0 return "second", if pf is 1 "seconds"
5426
5427[endsect]
5428
5429[section:do_get_unit_minutes Protected Member Function `do_get_unit(duration_style style,ratio<60>,std::size_t)`]
5430
5431      virtual string_type do_get_unit(duration_style style, ratio<60> u, std::size_t pf) const;
5432
5433__params
5434
5435* [param style] the duration style.
5436* [param period] the period associated to the duration hours.
5437* [param pf] the requested plural form.
5438
5439__returns if style is symbol returns "min", otherwise if pf is 0 return "minute", if pf is 1 "minutes"
5440
5441[endsect]
5442
5443[section:do_get_unit_hours Protected Member Function `do_get_unit(duration_style,ratio<3600>,std::size_t)`]
5444
5445      virtual string_type do_get_unit(duration_style style, ratio<3600> u, std::size_t pf) const;
5446
5447__params
5448
5449* [param style] the duration style.
5450* [param period] the period associated to the duration hours.
5451* [param pf] the requested plural form.
5452
5453__returns if style is symbol returns "h", otherwise if pf is 0 return "hour", if pf is 1 "hours"
5454
5455[endsect]
5456
5457[section:do_get_unit_xxx Protected Member Function `do_get_unit(duration_style,Period,std::size_t)`]
5458
5459      virtual string_type do_get_unit(duration_style style, atto u, std::size_t pf) const;
5460      virtual string_type do_get_unit(duration_style style, femto u, std::size_t pf) const;
5461      virtual string_type do_get_unit(duration_style style, pico u, std::size_t pf) const;
5462      virtual string_type do_get_unit(duration_style style, nano u, std::size_t pf) const;
5463      virtual string_type do_get_unit(duration_style style, micro u, std::size_t pf) const;
5464      virtual string_type do_get_unit(duration_style style, milli u, std::size_t pf) const;
5465      virtual string_type do_get_unit(duration_style style, centi u, std::size_t pf) const;
5466      virtual string_type do_get_unit(duration_style style, deci u, std::size_t pf) const;
5467      virtual string_type do_get_unit(duration_style style, deca u, std::size_t pf) const;
5468      virtual string_type do_get_unit(duration_style style, hecto u, std::size_t pf) const;
5469      virtual string_type do_get_unit(duration_style style, kilo u, std::size_t pf) const;
5470      virtual string_type do_get_unit(duration_style style, mega u, std::size_t pf) const;
5471      virtual string_type do_get_unit(duration_style style, giga u, std::size_t pf) const;
5472      virtual string_type do_get_unit(duration_style style, tera u, std::size_t pf) const;
5473      virtual string_type do_get_unit(duration_style style, peta u, std::size_t pf) const;
5474      virtual string_type do_get_unit(duration_style style, exa u, std::size_t pf) const;
5475
5476__params
5477
5478* [param style] the duration style.
5479* [param u] the period tag atto.
5480* [param pf] the requested plural form.
5481
5482__returns the concatenation of the prefix associated to period `u` + the one associated to seconds.
5483
5484[endsect]
5485
5486[section:do_get_ratio_prefix_xxx Protected Member Function `do_get_ratio_prefix(duration_style, Period)`]
5487
5488      virtual string_type do_get_ratio_prefix(duration_style style, atto u) const;
5489      virtual string_type do_get_ratio_prefix(duration_style style, femto u) const;
5490      virtual string_type do_get_ratio_prefix(duration_style style, pico u) const;
5491      virtual string_type do_get_ratio_prefix(duration_style style, nano u) const;
5492      virtual string_type do_get_ratio_prefix(duration_style style, micro u) const;
5493      virtual string_type do_get_ratio_prefix(duration_style style, milli u) const;
5494      virtual string_type do_get_ratio_prefix(duration_style style, centi u) const;
5495      virtual string_type do_get_ratio_prefix(duration_style style, deci u) const;
5496      virtual string_type do_get_ratio_prefix(duration_style style, deca u) const;
5497      virtual string_type do_get_ratio_prefix(duration_style style, hecto u) const;
5498      virtual string_type do_get_ratio_prefix(duration_style style, kilo u) const;
5499      virtual string_type do_get_ratio_prefix(duration_style style, mega u) const;
5500      virtual string_type do_get_ratio_prefix(duration_style style, giga u) const;
5501      virtual string_type do_get_ratio_prefix(duration_style style, tera u) const;
5502      virtual string_type do_get_ratio_prefix(duration_style style, peta u) const;
5503      virtual string_type do_get_ratio_prefix(duration_style style, exa u) const;
5504
5505__params
5506
5507* [param style] the duration style.
5508* [param u] the period tag atto.
5509
5510__returns depending on the value of `style` return the ratio_string symbol or prefix.
5511
5512[endsect]
5513
5514
5515[endsect] [/section:duration_units_default]
5516
5517[endsect] [/section:duration_units_hpp]
5518
5519[/==================================================================]
5520[section:duration_io_hpp Header `<boost/chrono/io/duration_io.hpp>`]
5521[/==================================================================]
5522
5523    namespace boost {
5524      namespace chrono {
5525
5526        // manipulators
5527
5528        std::ios_base& __symbol_format(ios_base& ios);
5529        std::ios_base& __name_format(ios_base& ios);
5530        class __duration_fmt;
5531        template<class CharT, class Traits>
5532        std::basic_ostream<CharT, Traits>&
5533        __duration_fmt__op_out(std::basic_ostream<CharT, Traits>& os, duration_fmt d);
5534
5535        template<class CharT, class Traits>
5536        std::basic_istream<CharT, Traits>&
5537        __duration_fmt__op_in(std::basic_istream<CharT, Traits>& is, duration_fmt d);
5538
5539
5540        // duration I/O
5541
5542        template <class CharT, class Traits, class Rep, class Period>
5543            std::basic_ostream<CharT, Traits>&
5544            __duration__op_out(std::basic_ostream<CharT, Traits>& os, const __duration<Rep, Period>& d);
5545
5546        template <class CharT, class Traits, class Rep, class Period>
5547            std::basic_istream<CharT, Traits>&
5548            __duration__op_in(std::basic_istream<CharT, Traits>& is, __duration<Rep, Period>& d)
5549
5550      }
5551    }
5552
5553
5554[section:manipulators I/O Manipulators]
5555
5556There is a parameterized manipulator that takes the duration_style as parameter.
5557The symbol or name format can be easily chosen by streaming a `symbol_format` or `name_format` manipulators respectively.
5558
5559[section:duration_fmt Template Class `duration_fmt`]
5560
5561        class duration_fmt
5562        {
5563        public:
5564
5565          explicit __duration_fmt__c1(__duration_style style) noexcept;
5566
5567        #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
5568          explicit
5569          __duration_fmt__op_duration_style() const noexcept;
5570        #endif
5571          __duration_style __duration_fmt__get_duration_style() const noexcept;
5572        };
5573
5574        template<class CharT, class Traits>
5575        std::basic_ostream<CharT, Traits>&
5576        __duration_fmt__op_out(std::basic_ostream<CharT, Traits>& os, duration_fmt d);
5577
5578        template<class CharT, class Traits>
5579        std::basic_istream<CharT, Traits>&
5580        __duration_fmt__op_in(std::basic_istream<CharT, Traits>& is, duration_fmt d);
5581
5582
5583[section:c1 Constructor `duration_fmt(duration_style)`]
5584
5585  explicit duration_fmt(duration_style f) noexcept;
5586
5587__effects Constructs a __duration_fmt by storing `f`.
5588
5589__postcondition `static_cast<duration_style>(*this) == f`.
5590
5591[endsect]
5592[section:op_duration_style Member Function `operator duration_style()`]
5593
5594  explicit operator duration_style() const noexcept;
5595  duration_style get_duration_style() const noexcept;
5596
5597__returns: The stored __duration_fmt `f`.
5598
5599[endsect]
5600[section:op_out Member Function `operator <<(basic_ostream<>&, duration_fmt)`]
5601
5602  template<class CharT, class Traits>
5603    basic_ostream<CharT, Traits>&
5604    operator<<(basic_ostream<CharT, Traits>& s, duration_fmt d);
5605
5606__effects: `__set_duration_style(s, static_cast<__duration_style>(d))))`.
5607
5608__returns: `s`.
5609
5610[endsect]
5611[section:op_in Member Function `operator >>(basic_istream<>&, duration_fmt)`]
5612
5613  template<class CharT, class Traits>
5614    basic_istream<CharT, Traits>&
5615    operator>>(basic_istream<CharT, Traits>& s, duration_fmt d);
5616
5617__effects: `__set_duration_style(s, static_cast<__duration_style>(d))))`.
5618
5619__returns: `s`.
5620
5621[endsect]
5622[endsect]
5623
5624[section:symbol_format Non Member Function `symbol_format(ios_base&)`]
5625
5626        std::ios_base& __symbol_format(ios_base& ios);
5627
5628__effects: `__set_duration_style(s, __duration_style::symbol)`.
5629
5630__returns `ios`
5631
5632[endsect]
5633[section:name_format Non Member Function `name_format(ios_base&)`]
5634
5635        std::ios_base& __name_format(ios_base& ios);
5636
5637__effects: `__set_duration_style(s, __duration_style::prefix)`.
5638
5639__returns `ios`
5640
5641
5642[endsect]
5643[endsect]
5644
5645
5646[section:streams I/O Streams Operations]
5647
5648[section:duration__op_out Member Function `operator <<(basic_ostream<>&, const duration<>& d)`]
5649
5650Any __duration can be streamed out to a `basic_ostream`.
5651The run-time value of the __duration is formatted according to the rules and current format settings for __duration`::rep` and the __duration_units facet.
5652
5653
5654        template <class CharT, class Traits, class Rep, class Period>
5655            std::basic_ostream<CharT, Traits>&
5656            operator<<(std::basic_ostream<CharT, Traits>& os, const duration<Rep, Period>& d);
5657
5658__effects Behaves as a formatted output function.
5659After constructing a sentry object, if the sentry converts to true,
5660calls to `facet.__duration_put_put(os,os,os.fill(),d)` where `facet` is the `__duration_put<CharT>`
5661facet associated to `os` or a new created instance of the default `__duration_put<CharT>` facet.
5662
5663__returns `os`.
5664
5665[endsect]
5666[section:duration__op_in Member Function `operator <<(basic_istream<>&, const duration<>& d)`]
5667
5668        template <class CharT, class Traits, class Rep, class Period>
5669            std::basic_istream<CharT, Traits>&
5670            operator>>(std::basic_istream<CharT, Traits>& is, duration<Rep, Period>& d)
5671
5672__effects Behaves as a formatted input function. After constructing a `sentry` object, if the `sentry`
5673converts to `true`, calls to `facet.__duration_get_get(is,std::istreambuf_iterator<CharT, Traits>(), is, err, d)` where `facet` is the `__duration_get<CharT>`
5674facet associated to `is` or a new created instance of the default `__duration_get<CharT>` facet.
5675
5676If any step fails, calls `os.setstate(std::ios_base::failbit | std::ios_base::badbit)`.
5677
5678__returns `is`
5679[endsect]
5680
5681[endsect]
5682
5683
5684[endsect] [/section:duration_io_hpp Header `<boost/chrono/io/duration_io.hpp>`]
5685
5686[/==================================================================]
5687[section:time_point_get_hpp Header `<boost/chrono/io/time_point_get.hpp>`]
5688[/==================================================================]
5689
5690    namespace boost {
5691      namespace chrono {
5692        template <class CharT, class InputIterator = std::istreambuf_iterator<CharT> >
5693        class time_point_get;
5694      }
5695    }
5696
5697[section:time_point_get Template Class `time_point_get`]
5698
5699    template <class CharT, class InputIterator = std::istreambuf_iterator<CharT> >
5700    class time_point_get: public std::locale::facet
5701    {
5702    public:
5703      typedef CharT char_type; // Type of character the facet is instantiated on.
5704      typedef InputIterator iter_type; // Type of iterator used to scan the character buffer.
5705
5706      explicit __time_point_get_c(size_t refs = 0);
5707
5708      template <class Clock, class Duration>
5709      iter_type __time_point_get_get(iter_type i, iter_type e, std::ios_base& is, std::ios_base::iostate& err,
5710          time_point<Clock, Duration> &tp, const char_type *pattern, const char_type *pat_end) const;
5711
5712      template <class Clock, class Duration>
5713      iter_type __time_point_get_get2(iter_type i, iter_type e, std::ios_base& is, std::ios_base::iostate& err,
5714          time_point<Clock, Duration> &tp) const;
5715
5716      template <typename Rep, typename Period>
5717      iter_type __time_point_get_get_duration(iter_type i, iter_type e, std::ios_base& is, std::ios_base::iostate& err,
5718          duration<Rep, Period>& d) const;
5719
5720      template <class Clock>
5721      iter_type __time_point_get_get_epoch(iter_type i, iter_type e, std::ios_base& is, std::ios_base::iostate& err) const;
5722
5723      static std::locale::id id; // Unique identifier for this type of facet.
5724
5725      __time_point_get_d();
5726    };
5727
5728
5729`time_point_get` is used to parse a character sequence, extracting
5730the duration and the epoch into a class `time_point`.
5731
5732The pattern can contain the format specifiers `%d` and `%e` in any order.
5733
5734User confirmation is required for reliable parsing of
5735user-entered durations, but machine-generated formats can be parsed
5736reliably. This allows parsers to be aggressive about interpreting user
5737variations on standard formats.
5738
5739If the end iterator is reached during parsing the member function sets `std::ios_base::eofbit` in `err`.
5740
5741[section:c Constructor `time_point_get(size_t)`]
5742
5743      explicit time_point_get(size_t refs);
5744
5745Constructs a __time_point_get facet.
5746
5747__params
5748
5749* [param refs] references
5750
5751__effects Constructs a __duration_put facet.
5752If the `refs` argument is `0` then destruction of the object is
5753delegated to the locale, or locales, containing it. This allows
5754the user to ignore lifetime management issues. On the other had,
5755if `refs` is `1` then the object must be explicitly deleted;
5756`locale` will not do so. In this case, the object can be
5757maintained across the lifetime of multiple locales.
5758
5759[endsect]
5760
5761[section:d Destructor `~time_point_get()`]
5762
5763      ~time_point_get();
5764
5765__effects Destroy the facet.
5766
5767[endsect]
5768[section:get Template Member Function `get(iter_type,iter_type,std::ios_base&,std::ios_base::iostate&,time_point<Clock, Duration>&,const CharT*,const CharT*)`]
5769
5770      template <class Clock, class Duration>
5771      iter_type get(iter_type s, iter_type end, std::ios_base& ios, std::ios_base::iostate& err,
5772          time_point<Clock, Duration> &tp, const char_type *pattern, const char_type *pat_end) const;
5773
5774__params
5775
5776* [param s] start input stream iterator
5777* [param end] end input stream iterator
5778* [param ios] a reference to a `ios_base`
5779* [param err] the `ios_base::iostate`
5780* [param tp] the __time_point
5781* [param pattern] begin of the formatting pattern
5782* [param pat_end] end of the formatting pattern
5783
5784__requires `[pattern,pat_end)` must be a valid range.
5785
5786__effects: The function starts by evaluating `err = std::ios_base::goodbit`.
5787It then enters a loop, reading zero or more characters from `s` at
5788each iteration. Unless otherwise specified below, the loop
5789terminates when the first of the following conditions holds:
5790
5791* The expression `pattern == pat_end` evaluates to `true`.
5792* The expression `err == std::ios_base::goodbit` evaluates to `false`.
5793* The expression `s == end` evaluates to `true`, in which case the
5794function evaluates `err = std::ios_base::eofbit | std::ios_base::failbit`.
5795* The next element of pattern is equal to `'%'`, followed by a conversion
5796specifier character, the functions `get_duration` or `get_epoch` are called depending on
5797whether the format is `'d'` or `'e'`.
5798If the number of elements in the range `[pattern,pat_end)` is not
5799sufficient to unambiguously determine whether the conversion
5800specification is complete and valid, the function evaluates
5801`err |= std::ios_base::failbit`. Otherwise, the function evaluates
5802`s = do_get(s, end, ios, err, d)`. If `err == std::ios_base::goodbit` holds after
5803the evaluation of the expression, the function increments pattern to
5804point just past the end of the conversion specification and continues
5805looping.
5806* The expression `isspace(*pattern, ios.getloc())` evaluates to `true`, in
5807which case the function first increments `pattern` until
5808`pattern == pat_end || !isspace(*pattern, ios.getloc())` evaluates to `true`,
5809then advances `s` until `s == end || !isspace(*s, ios.getloc())` is `true`,
5810and finally resumes looping.
5811* The next character read from `s` matches the element pointed to by
5812pattern in a case-insensitive comparison, in which case the function
5813evaluates `++pattern`, `++s` and continues looping. Otherwise, the function
5814evaluates `err = std::ios_base::failbit`.
5815
5816__returns An iterator pointing just beyond the last character that can be determined to be part of a valid time_point.
5817
5818
5819[endsect]
5820[section:get2 Template Member Function `get(iter_type,iter_type,std::ios_base&,std::ios_base::iostate&,time_point<Clock,Duration>&)`]
5821
5822      template <class Clock, class Duration>
5823      iter_type get(iter_type s, iter_type end, std::ios_base& ios, std::ios_base::iostate& err,
5824          time_point<Clock, Duration> &tp) const;
5825
5826__params
5827
5828* [param s] start input stream iterator
5829* [param end] end input stream iterator
5830* [param ios] a reference to a `ios_base`
5831* [param err] the `ios_base::iostate`
5832* [param tp] the __time_point
5833
5834__effects Stores the duration pattern from the `duration_unit` facet in let say `str`. Last as if
5835
5836  return get(s, end, ios, err, ios, d, str.data(), str.data() + str.size());
5837
5838__returns An iterator pointing just beyond the last character that can be determined to be part of a valid name.
5839
5840[endsect]
5841[section:get_duration Template Member Function `get_duration(iter_type,iter_type,std::ios_base&,std::ios_base::iostate&,duration<Rep,Period>&)`]
5842
5843      template <typename Rep, typename Period>
5844      iter_type get_duration(iter_type s, iter_type end, std::ios_base& ios, std::ios_base::iostate& err,
5845          duration<Rep, Period>& d) const;
5846
5847__effects As if
5848
5849  return facet.get(s, end, ios, err, d);
5850
5851where `facet` is either the `duration_get` facet associated to the `ios` or an instance of the default `duration_get` facet.
5852
5853__returns An iterator pointing just beyond the last character that can be determined to be part of a valid duration.
5854
5855[endsect]
5856[section:get_epoch Template Member Function `get_epoch(iter_type,iter_type,std::ios_base&,std::ios_base::iostate&)`]
5857
5858      template <class Clock>
5859      iter_type get_epoch(iter_type s, iter_type end, std::ios_base& ios, std::ios_base::iostate& err) const;
5860
5861__effects  Let `facet` be the __time_point_units facet associated to `ios` or a new instance of the default __time_point_units_default facet.
5862Let `epoch` be the epoch string associated to the `Clock` using this facet.
5863Scans `s` to match `epoch` or `end` is reached.
5864
5865If not match before the `end` is reached `std::ios_base::failbit` is set in `err`.
5866If `end` is reached `std::ios_base::failbit` is set in `err`.
5867
5868__returns An iterator pointing just beyond the last character that can be determined to be part of a epoch.
5869
5870[endsect]
5871
5872[endsect] [/section:time_point_get]
5873
5874
5875[endsect] [/section:time_point_get_hpp]
5876
5877[/==================================================================]
5878[section:time_point_put_hpp Header `<boost/chrono/io/time_point_put.hpp>`]
5879[/==================================================================]
5880
5881    namespace boost {
5882      namespace chrono {
5883        template <class CharT, class OutputIterator = std::ostreambuf_iterator<CharT> >
5884        class time_point_put;
5885      }
5886    }
5887
5888
5889[section:time_point_put Template Class `time_point_put`]
5890
5891
5892The __time_point_put facet provides facilities for formatted output of __time_point values.
5893The member function of __time_point_put take a __time_point and format it into character string representation.
5894
5895tparam ChatT a character type
5896tparam OutputIterator a model of `OutputIterator`
5897
5898
5899    template <class CharT, class OutputIterator = std::ostreambuf_iterator<CharT> >
5900    class time_point_put: public std::locale::facet
5901    {
5902    public:
5903      typedef CharT char_type; // Type of character the facet is instantiated on.
5904      typedef std::basic_string<CharT> string_type; // Type of character string passed to member functions.
5905      typedef OutputIterator iter_type; // Type of iterator used to write in the character buffer.
5906
5907      explicit time_point_put(size_t refs = 0);
5908      ~time_point_put();
5909
5910      template <class Clock, class Duration>
5911      iter_type put(iter_type i, std::ios_base& ios, char_type fill, time_point<Clock, Duration> const& tp, const CharT* pattern,
5912          const CharT* pat_end) const;
5913      template <class Clock, class Duration>
5914      iter_type put(iter_type i, std::ios_base& ios, char_type fill, time_point<Clock, Duration> const& tp) const;
5915      template <typename Rep, typename Period>
5916      iter_type put_duration(iter_type i, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const;
5917      template <typename Clock>
5918      iter_type put_epoch(iter_type i, std::ios_base& os) const;
5919
5920      static std::locale::id id; // Unique identifier for this type of facet.
5921
5922
5923    };
5924
5925
5926[section:c Constructor `time_point_get(size_t)`]
5927
5928      explicit time_point_put(size_t refs = 0);
5929
5930
5931Construct a time_point_put facet.
5932
5933__effects Construct a time_point_put facet.
5934If the `refs` argument is `0` then destruction of the object is
5935delegated to the locale, or locales, containing it. This allows
5936the user to ignore lifetime management issues. On the other had,
5937if `refs` is `1` then the object must be explicitly deleted;
5938the locale will not do so. In this case, the object can be
5939maintained across the lifetime of multiple locales.
5940
5941__params
5942
5943* [param refs] references
5944
5945[endsect]
5946
5947[section:put1 Member Function `put()`]
5948
5949      template <class Clock, class Duration>
5950      iter_type put(iter_type i, std::ios_base& ios, char_type fill, time_point<Clock, Duration> const& tp, const CharT* pattern,
5951          const CharT* pat_end) const;
5952
5953
5954__params
5955
5956* [param i] an output stream iterator
5957* [param ios] a reference to a ios_base
5958* [param fill] the character used as filler
5959* [param tp] the __time_point
5960* [param pattern] begin of the formatting pattern
5961* [param pat_end] end of the formatting pattern
5962
5963__effects Steps through the sequence from `pattern` to `pat_end`,
5964identifying characters that are part of a pattern sequence. Each character
5965that is not part of a pattern sequence is written to `s` immediately, and
5966each pattern sequence, as it is identified, results in a call to
5967__put_duration or __put_epoch;
5968thus, pattern elements and other characters are interleaved in the output
5969in the order in which they appear in the pattern. Pattern sequences are
5970identified by converting each character `c` to a `char` value as if by
5971`ct.narrow(c,0)`, where `ct` is a reference to `ctype<charT>` obtained from
5972`ios.getloc()`. The first character of each sequence is equal to `'%'`,
5973followed by a pattern specifier character spec, which can be `'d'` for
5974the duration value or `'e'` for the epoch.
5975For each valid pattern sequence identified, calls
5976`put_duration(s, ios, fill, tp.time_since_epoch())` or `put_epoch(s, ios)`.
5977
5978__returns An iterator pointing immediately after the last character produced.
5979
5980[endsect]
5981
5982[section:put2 Member Function `put()`]
5983
5984      template <class Clock, class Duration>
5985      iter_type put(iter_type i, std::ios_base& ios, char_type fill, time_point<Clock, Duration> const& tp) const;
5986
5987__params
5988
5989* [param i] an output stream iterator
5990* [param ios] a reference to a ios_base
5991* [param fill] the character used as filler
5992* [param tp] the __time_point
5993* [param tern] begin of the formatting pattern
5994* [param pat_end] end of the formatting pattern
5995
5996__effects Stores the time_point pattern from the __time_point_unit facet in let say `str`. Last as if
5997
5998  return put(s, ios, fill, tp, str.data(), str.data() + str.size());
5999
6000__returns An iterator pointing immediately after the last character produced.
6001
6002[endsect]
6003
6004[section:put_duration Member Function `put_duration()`]
6005
6006      template <typename Rep, typename Period>
6007      iter_type put_duration(iter_type i, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const;
6008
6009__params
6010
6011* [param i] an output stream iterator
6012* [param ios] a reference to a ios_base
6013* [param fill] the character used as filler
6014* [param d] the __duration
6015
6016__effects As if `facet.put(s, ios, fill, d)` where facet is the `__duration_put<CharT>` facet associated
6017to the `ios` or a new instance of `__duration_put<CharT>`.
6018
6019__returns An iterator pointing immediately after the last character produced.
6020
6021[endsect]
6022
6023[section:put_epoch Member Function `put_epoch()`]
6024
6025      template <typename Clock>
6026      iter_type put_epoch(iter_type i, std::ios_base& os) const;
6027
6028__params
6029
6030* [param i] an output stream iterator
6031* [param ios] a reference to a ios_base
6032
6033__effects As if
6034
6035  string_type str = facet.template get_epoch<Clock>();
6036  s=std::copy(str.begin(), str.end(), s);
6037
6038
6039where facet is the `__time_point_units<CharT>` facet associated
6040to the `ios` or a new instance of `__time_point_units_default<CharT>`.
6041
6042__returns s, iterator pointing immediately after the last character produced.
6043
6044[endsect]
6045
6046[endsect]
6047
6048[endsect] [/section:time_point_put_hpp]
6049
6050[/==================================================================]
6051[section:time_point_units_hpp Header `<boost/chrono/io/time_point_units.hpp>`]
6052[/==================================================================]
6053
6054    namespace boost {
6055      namespace chrono {
6056        template <typename CharT, typename Clock, typename TPUFacet>
6057        std::basic_string<CharT> get_epoch_custom(Clock, TPUFacet& f);
6058        template <typename CharT=char>
6059        class time_point_units;
6060        template <typename CharT=char>
6061        class time_point_units_default,
6062      }
6063    }
6064
6065[section:get_epoch_custom Template Function `get_epoch_custom`]
6066
6067        template <typename CharT, typename Clock, typename TPUFacet>
6068        std::basic_string<CharT> get_epoch_custom(Clock, TPUFacet& f);
6069
6070
6071Customization point to the epoch associated to the clock `Clock`
6072The default calls `f.do_get_epoch(Clock())`.
6073
6074The user can overload this function.
6075
6076
6077__returns Forwards the call to the facet as if
6078
6079      return f.do_get_epoch(Clock());
6080
6081
6082[endsect]
6083[//////////////////////////////////////////////////////////]
6084[section:time_point_units Template Class `time_point_units`]
6085
6086
6087__time_point_units facet gives useful information about the time_point pattern,
6088the text associated to a time_point's epoch,
6089
6090    template <typename CharT=char>
6091    class time_point_units: public std::locale::facet
6092    {
6093    public:
6094      typedef CharT char_type; // Type of character the facet is instantiated on.
6095      typedef std::basic_string<char_type> string_type; // Type of character string used by member functions.
6096      static std::locale::id id; // Unique identifier for this type of facet.
6097
6098      explicit time_point_units(size_t refs = 0);
6099
6100      virtual string_type get_pattern() const =0;
6101      template <typename Clock>
6102      string_type get_epoch() const;
6103
6104    protected:
6105      virtual ~time_point_units();
6106      virtual string_type do_get_epoch(system_clock) const=0;
6107      virtual string_type do_get_epoch(steady_clock) const=0;
6108
6109  #if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
6110      virtual string_type do_get_epoch(process_real_cpu_clock) const=0;
6111      virtual string_type do_get_epoch(process_user_cpu_clock) const=0;
6112      virtual string_type do_get_epoch(process_system_cpu_clock) const=0;
6113      virtual string_type do_get_epoch(process_cpu_clock) const=0;
6114  #endif
6115  #if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
6116      virtual string_type do_get_epoch(thread_clock) const=0;
6117  #endif
6118
6119    };
6120
6121
6122[section:c Constructor `time_point_units()`]
6123
6124      explicit time_point_units(size_t refs = 0);
6125
6126Construct a __time_point_units facet.
6127
6128__params
6129
6130* [param refs] references
6131
6132__effects Construct a __time_point_units facet.
6133If the `refs` argument is `0` then destruction of the object is
6134delegated to the locale, or locales, containing it. This allows
6135the user to ignore lifetime management issues. On the other had,
6136if `refsv is `1` then the object must be explicitly deleted;
6137the locale will not do so. In this case, the object can be
6138maintained across the lifetime of multiple locales.
6139
6140[endsect]
6141
6142[section:get_pattern Member Function `get_pattern()`]
6143
6144      virtual string_type get_pattern() const =0;
6145
6146__returns the pattern to be used by default.
6147
6148[endsect]
6149
6150[section:get_epoch Member Function `get_epoch()`]
6151
6152      template <typename Clock>
6153      string_type get_epoch() const;
6154
6155__returns the epoch associated to the clock `Clock` as if `return get_epoch_custom<CharT>(Clock(), *this);
6156`
6157
6158[endsect]
6159
6160[section:d Destructor `time_point_units()`]
6161
6162      virtual ~time_point_units();
6163
6164Destroy the facet.
6165
6166[endsect]
6167
6168[section:do_get_epoch_system_clock Member Function `do_get_epoch(system_clock)`]
6169
6170      virtual string_type do_get_epoch(system_clock) const=0;
6171
6172__params
6173
6174* [param c] a dummy instance of __system_clock.
6175
6176__returns The epoch string associated to the __system_clock.
6177
6178[endsect]
6179
6180[section:do_get_epoch_steady_clock Member Function `do_get_epoch(steady_clock)`]
6181
6182      virtual string_type do_get_epoch(steady_clock) const=0;
6183
6184__params
6185
6186* [param c] a dummy instance of __steady_clock.
6187
6188__returns The epoch string associated to the __steady_clock.
6189
6190[endsect]
6191
6192[section:do_get_epoch_process_real_cpu_clock Member Function `do_get_epoch(process_real_cpu_clock)`]
6193
6194  #if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
6195      virtual string_type do_get_epoch(process_real_cpu_clock) const=0;
6196  #endif
6197
6198__params
6199
6200* [param c] a dummy instance of __process_real_cpu_clock.
6201
6202__returns The epoch string associated to the __process_real_cpu_clock.
6203
6204[endsect]
6205
6206[section:do_get_epoch_process_user_cpu_clock Member Function `do_get_epoch(process_user_cpu_clock)`]
6207
6208  #if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
6209      virtual string_type do_get_epoch(process_user_cpu_clock) const=0;
6210  #endif
6211
6212__params
6213
6214* [param c] a dummy instance of __process_real_cpu_clock.
6215
6216__returns The epoch string associated to the process_user_cpu_clock.
6217
6218[endsect]
6219
6220[section:do_get_epoch_process_system_cpu_clock Member Function `do_get_epoch(process_system_cpu_clock)`]
6221
6222  #if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
6223      virtual string_type do_get_epoch(process_system_cpu_clock) const=0;
6224  #endif
6225
6226__params
6227
6228* [param c] a dummy instance of __process_system_cpu_clock.
6229
6230__returns The epoch string associated to the process_user_cpu_clock.
6231
6232[endsect]
6233
6234[section:do_get_epoch_process_process_cpu_clock Member Function `do_get_epoch(process_cpu_clock)`]
6235
6236  #if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
6237      virtual string_type do_get_epoch(process_cpu_clock) const=0;
6238  #endif
6239
6240__params
6241
6242* [param c] a dummy instance of __process_cpu_clock.
6243
6244__returns The epoch string associated to the process_cpu_clock.
6245
6246[endsect]
6247
6248[section:do_get_epoch_process_thread_clock Member Function `do_get_epoch(thread_clock)`]
6249
6250  #if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
6251      virtual string_type do_get_epoch(thread_clock) const=0;
6252  #endif
6253
6254__params
6255
6256* [param c] a dummy instance of __thread_clock.
6257
6258__returns The epoch string associated to the __thread_clock.
6259
6260[endsect]
6261
6262
6263[endsect]
6264[section:time_point_units_default Template Class `time_point_units_default`]
6265
6266    // This class is used to define the strings for the default English
6267    template <typename CharT=char>
6268    class time_point_units_default: public time_point_units<CharT>
6269    {
6270    public:
6271      typedef CharT char_type; // Type of character the facet is instantiated on.
6272      typedef std::basic_string<char_type> string_type; // Type of character string used by member functions.
6273
6274      explicit time_point_units_default(size_t refs = 0);
6275      ~time_point_units_default();
6276
6277      /**
6278       * __returns the default pattern "%d%e".
6279       */
6280      string_type get_pattern() const;
6281
6282    protected:
6283      /**
6284       * [param c a dummy instance of __system_clock.
6285       * __returns The epoch string returned by `clock_string<system_clock,CharT>::since()`.
6286       */
6287      string_type do_get_epoch(system_clock ) const;
6288      /**
6289       * [param c a dummy instance of __steady_clock.
6290       * __returns The epoch string returned by `clock_string<steady_clock,CharT>::since()`.
6291       */
6292      string_type do_get_epoch(steady_clock ) const;
6293  #if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
6294      /**
6295       * [param c a dummy instance of __process_real_cpu_clock.
6296       * __returns The epoch string returned by `clock_string<process_real_cpu_clock,CharT>::since()`.
6297       */
6298      string_type do_get_epoch(process_real_cpu_clock ) const;
6299      /**
6300       * [param c a dummy instance of __process_user_cpu_clock.
6301       * __returns The epoch string returned by `clock_string<process_user_cpu_clock,CharT>::since()`.
6302       */
6303      string_type do_get_epoch(process_user_cpu_clock ) const;
6304      /**
6305       * [param c a dummy instance of __process_system_cpu_clock.
6306       * __returns The epoch string returned by `clock_string<process_system_cpu_clock,CharT>::since()`.
6307       */
6308      string_type do_get_epoch(process_system_cpu_clock ) const;
6309      /**
6310       * [param c a dummy instance of __process_cpu_clock.
6311       * __returns The epoch string returned by `clock_string<process_cpu_clock,CharT>::since()`.
6312       */
6313      string_type do_get_epoch(process_cpu_clock ) const;
6314
6315  #endif
6316  #if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
6317      /**
6318       * [param c a dummy instance of __thread_clock.
6319       * __returns The epoch string returned by `clock_string<thread_clock,CharT>::since()`.
6320       */
6321      string_type do_get_epoch(thread_clock ) const;
6322  #endif
6323
6324    };
6325
6326[endsect]
6327[endsect] [/section:time_point_units_hpp]
6328
6329
6330[/==================================================================]
6331[section:time_point_io_hpp Header `<boost/chrono/io/time_point_io.hpp>`]
6332[/==================================================================]
6333
6334
6335    namespace boost {
6336    namespace chrono {
6337
6338
6339        // manipulators
6340
6341        unspecified __time_fmt1(timezone tz);
6342        template<class CharT>
6343        unspecified __time_fmt2(timezone tz, basic_string<CharT> f);
6344        template<class CharT>
6345        unspecified __time_fmt2(timezone tz, const CharT* f);
6346
6347        // i/o state savers
6348
6349        template<typename CharT = char, typename Traits = std::char_traits<CharT> >
6350        struct __timezone_io_saver
6351        {
6352          typedef std::basic_ios<CharT, Traits> state_type;
6353          typedef timezone aspect_type;
6354
6355          explicit __timezone_io_saver__c1(state_type &s);
6356          __timezone_io_saver__c2(state_type &s, aspect_type new_value);
6357          __timezone_io_saver__d();
6358          void timezone_io_saver__restore();
6359        };
6360
6361        template<typename CharT = char, typename Traits = std::char_traits<CharT> >
6362        struct __time_fmt_io_saver
6363        {
6364          typedef std::basic_ios<CharT, Traits> state_type;
6365
6366          explicit time_fmt_io_saver(state_type &s);
6367          time_fmt_io_saver(state_type &s, basic_string<CharT> const& new_value);
6368          ~ time_fmt_io_saver();
6369          void restore();
6370        };
6371
6372        // system_clock I/O
6373
6374        template <class CharT, class Traits, class __Duration>
6375          basic_ostream<CharT, Traits>&
6376          operator<<(basic_ostream<CharT, Traits>& os,
6377                     const time_point<system_clock, __Duration>& tp);
6378
6379        template <class CharT, class Traits, class __Duration>
6380          basic_istream<CharT, Traits>&
6381          operator>>(basic_istream<CharT, Traits>& is,
6382                     time_point<system_clock, __Duration>& tp);
6383
6384        // Other Clocks I/O
6385
6386        template <class CharT, class Traits, class __Clock, class __Duration>
6387            std::basic_ostream<CharT, Traits>&
6388            operator<<(std::basic_ostream<CharT, Traits>& os,
6389                   const time_point<__Clock, __Duration>& tp);
6390
6391        template <class CharT, class Traits, class __Clock, class __Duration>
6392            std::basic_istream<CharT, Traits>&
6393            operator>>(std::basic_istream<CharT, Traits>& is,
6394                   time_point<__Clock, __Duration>& tp);
6395
6396    }
6397    }
6398
6399
6400
6401[section:manip I/O Manipulators]
6402[section:time_fmt1 Non Member Function `time_fmt(__timezone)` ]
6403
6404  unspecified time_fmt(__timezone tz);
6405
6406__returns: An unspecified object that when streamed to a `basic_ostream<CharT, Traits>` or `basic_istream<CharT, Traits>` `s` will have the effects of:
6407
6408          __set_timezone(s, tz);
6409
6410[endsect]
6411
6412[section:time_fmt2 Non Member Function `time_fmt(__timezone, string)` ]
6413
6414  template<class CharT>
6415    unspecified time_fmt(timezone tz, basic_string<CharT> f);
6416  template<class CharT>
6417    unspecified time_fmt(timezone tz, const CharT* f);
6418
6419__returns: An unspecified object that when streamed to a `basic_ostream<CharT, Traits>` or `basic_istream<CharT, Traits>` `s` will have the effects of:
6420
6421          __set_timezone(s, tz);
6422          __set_time_fmt<CharT>(s, f);
6423
6424[endsect]
6425[endsect]
6426
6427
6428
6429[section:streams I/O Streams Operations]
6430
6431[section:system_clock `system_clock`]
6432
6433[/warning
6434
6435The time_point<system_clock,D> formatter/parser specializations don't work yet. It has been disable defining `BOOST_CHRONO_DONT_PROVIDE_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT` until a fix for the following ticket is found:
6436
6437- [@http://svn.boost.org/trac/boost/ticket/7547 #7547] time_point<system_clock> input version 2 fails to compile
6438
6439- [@http://svn.boost.org/trac/boost/ticket/7546 #7546] time_point<system_clock> output version 2 fails to compile
6440
6441In this case the io operators behave like any time_point as if the specialization was removed.
6442
6443In order to enable this features on compilers working with, you will need to define `BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT`.
6444
6445]
6446
6447[section:op_out Non Member Function `operator<<()`]
6448
6449        template <class CharT, class Traits, class __Duration>
6450            std::basic_ostream<CharT, Traits>&
6451            operator<<(std::basic_ostream<CharT, Traits>& os,
6452                   const time_point<system_clock, __Duration>& tp);
6453
6454__effects Behaves as a formatted output function. After constructing a `sentry` object, if the `sentry` converts to
6455`true`, sets a local variable `tz` of type __timezone to `get_timezone(os)`.
6456Additionally the format string obtained with `__get_time_fmt()` is recorded as a pair of `const CharT*`.
6457If the stream has no time_punct facet, then this pair of `const CharT*` that represent an empty range.
6458
6459Next `tp` is converted to a `time_t`, and this `time_t` is converted to a `tm`.
6460The conversion to `tm` use `gmtime` (when available) if the timezone is __utc, else it use localtime (if available).
6461
6462Using the `std::time_put` facet stored in `os`, this inserter writes characters to the stream using the `tm` and the
6463formatting string stored in the `time_punct` facet, unless that facet was missing, or unless it provided an empty string.
6464
6465If the formatting string is empty, then output as follows:
6466
6467First output `tm` using `"%F %H:%M:"`
6468
6469Next output a `double` representing the number of seconds stored in the `tm` plus the fractional seconds represented
6470in `tp`. The format shall be `ios::fixed` and the precision shall be sufficient to represent `system_clock::duration`
6471exactly (e.g. if `system_clock::period` is micro, the precision should be sufficient to output six digits following
6472the decimal point). If the number of seconds is less than `10`, the output shall be prefixed by `'0'`.
6473
6474Finally if `tz` is __local, output the `tm` using the pattern " %z". Else append the sequence " +0000" to the stream.
6475
6476If any step fails, calls `os.setstate(ios_base::failbit | ios_base::badbit)`.
6477
6478__returns `os`
6479
6480[endsect]
6481[section:op_in Non Member Function `operator>>()`]
6482
6483        template <class CharT, class Traits, class __Duration>
6484            std::basic_istream<CharT, Traits>&
6485            operator>>(std::basic_istream<CharT, Traits>& is,
6486                   time_point<system_clock, __Duration>& tp);
6487
6488__effects Behaves as a formatted input function. After constructing a sentry object, if the sentry converts to true,
6489obtains a `std::time_get` facet from `is`, and obtains a formatting string in the same manner as described for
6490insertion operator. Extract a `tm` using the supplied formatting string, or if empty, defaulted as described for the
6491insertion operator. Note that extraction does not use the __timezone data stored in the `is` for the
6492defaulted string as the __timezone information is stored in the stream.
6493
6494Any `time_point<system_clock, __Duration>` inserted, and then extracted should result in an equal
6495`time_point<system_clock, __Duration>`, excepting any precision that did not get inserted.
6496
6497__example
6498
6499    void test(std::chrono::system_clock::time_point tp)
6500    {
6501        std::stringstream s;
6502        s << tp;
6503        boost::chrono::system_clock::time_point tp2;
6504        s >> tp2;
6505        assert(tp == tp2);
6506    }
6507
6508__returns is
6509
6510[endsect]
6511
6512[endsect]
6513
6514
6515[section:other_clocks Other Clocks]
6516[section:op_out Non Member Function `operator<<()`]
6517
6518
6519        template <class CharT, class Traits, class __Clock, class __Duration>
6520            std::basic_ostream<CharT, Traits>&
6521            operator<<(std::basic_ostream<CharT, Traits>& os,
6522                   const time_point<__Clock, __Duration>& tp);
6523
6524__effects Behaves as a formatted output function. After constructing a `sentry` object, if the `sentry`
6525converts to `true`, calls to `facet.put(os,os,os.fill(),tp)` where `facet` is the `time_point_put<CharT>`
6526facet associated to `os` or a new created instance of the default `time_point_put<CharT>` facet.
6527
6528__returns `os`.
6529
6530__example
6531
6532    22644271279698 nanoseconds since boot
6533
6534
6535[endsect]
6536[section:op_in Non Member Function `operator>>()`]
6537
6538        template <class CharT, class Traits, class __Clock, class __Duration>
6539            std::basic_istream<CharT, Traits>&
6540            operator>>(std::basic_istream<CharT, Traits>& is,
6541                   time_point<__Clock, __Duration>& tp);
6542
6543Extracts `tp` from the stream `is`.
6544
6545__effects Behaves as a formatted input function. After constructing a `sentry` object, if the `sentry`
6546converts to `true`, calls to `facet.get(is,std::istreambuf_iterator<CharT, Traits>(), is, err, tp)` where `facet` is the `time_point_get<CharT>`
6547facet associated to `is` or a new created instance of the default `time_point_get<CharT>` facet.
6548
6549If any step fails, calls `os.setstate(std::ios_base::failbit | std::ios_base::badbit)`.
6550
6551__returns `is`.
6552
6553[endsect]
6554
6555[endsect]
6556[endsect]
6557
6558
6559
6560[endsect] [/section:time_point_io_hpp Header `<boost/chrono/io/time_point_io.hpp>`]
6561
6562
6563
6564[/
6565[/==================================================================]
6566[section:duration_unit_string_hpp Header `<boost/chrono/io/duration_unit_string.hpp>`]
6567[/==================================================================]
6568
6569    namespace boost { namespace chrono {
6570
6571      template <class Period, class CharT>
6572      struct duration_period_strings
6573      {
6574        static std::basic_string<CharT> plural();
6575        static std::basic_string<CharT> singular();
6576        static std::basic_string<CharT> symbol();
6577      };
6578
6579      template <class Period, class CharT>
6580      struct duration_period
6581      {
6582        static std::basic_string<CharT> prefix(std::basic_string<CharT> const& translation);
6583        static std::basic_string<CharT> symbol();
6584      };
6585
6586      template <class CharT, class Rep, class Period>
6587      std::basic_string<CharT> duration_unit_string(
6588        bool is_prefix,
6589        duration<Rep,Period> const& d);
6590
6591    } }
6592
6593[section:duration_period_suffix Template Class `duration_period_suffix<>`]
6594
6595[endsect]
6596
6597[section: duration_unit_string Non Member Function `duration_unit_string()`]
6598
6599      template <class CharT, class Rep, class Period>
6600      std::basic_string<CharT> duration_unit_string(
6601        bool is_prefix,
6602        duration<Rep,Period> const& d);
6603
6604First units are obtained from `Period::type` and stored in two `basic_string<CharT>` (e.g. singular/plural) according to the following rules:
6605
6606* If `is_prefix` is `true`
6607
6608  * If `Period::type` is `ratio<3600>`, `singular` is set to `"hour"` and  `plural` is set to `"hours"`.
6609  * Else if `Period::type` is `ratio<60>`, `singular` is set to `"minute"` and `plural ` is set to `"minutes"`.
6610  * Else if `Period::type` is `ratio<1>` `singular` is set to `"second"` and `plural ` is set to `"seconds"`.
6611  * Else `singular ` is set to `ratio_string<Period, CharT>::prefix() + "second"` and `plural ` is set to `ratio_string<Period, CharT>::prefix() + "seconds"`.
6612
6613Finally the intermediary unit string obtained by calling __duration_prefix_translate function with the `singular`, `plural` and the duration `d` as parameters.
6614
6615* If `is_prefix` is `true`
6616
6617  * If `Period::type` is `ratio<3600>` `symbol` is set to `"h"`.
6618  * Else if `Period::type` is `ratio<60>` `symbol` is set to `"min"`.
6619  * Else if `Period::type` is `ratio<1>` `symbol` is set to `"s"`.
6620  * Else `symbol` is set to `ratio_string<Period, CharT>::symbol() + "s"`.
6621
6622Finally the intermediary unit string is obtained by calling duration_symbol_translate function
6623
6624Note: The string literals above need to be converted to the correct literal type to be assigned to a `basic_string<CharT>`.
6625
6626[endsect]
6627
6628[endsect] [/section:duration_units_string_hpp Header `<boost/chrono/io/duration_uinit_string.hpp>`]
6629
6630[/==================================================================]
6631[section:translate_hpp Header `<boost/chrono/io/translate.hpp>`]
6632[/==================================================================]
6633
6634    namespace boost { namespace chrono {
6635
6636    #if !defined BOOST_CHRONO_SPECIFIC_TRANSLATE
6637      template <class CharT, class Rep>
6638      std::basic_string<CharT> duration_prefix_translate(
6639        std::basic_string<CharT> const &singular,
6640        std::basic_string<CharT> const &plural,
6641        Rep v);
6642
6643      template <class CharT>
6644      std::basic_string<CharT> duration_symbol_translate(
6645        std::basic_string<CharT> const &symbol);
6646
6647      template <class CharT>
6648      std::basic_string<CharT> epoch_translate(
6649        std::basic_string<CharT> const &epoch);
6650
6651    #endif
6652
6653
6654    } }
6655
6656The library provides a default implementation of these translation function if BOOST_CHRONO_SPECIFIC_TRANSLATE is not defined.
6657
6658The user can provide its single specific implementation by ensuring that equivalent prototypes are provided before their use is needed and BOOST_CHRONO_SPECIFIC_TRANSLATE is defined.
6659
6660Next follow the behavior of the default implementation.
6661
6662[section:duration_prefix_translate Non Member Function `duration_prefix_translate()`]
6663
6664      template <class CharT, class Rep>
6665      std::basic_string<CharT> duration_prefix_translate(
6666        std::basic_string<CharT> const &singular,
6667        std::basic_string<CharT> const &plural,
6668        Rep r);
6669
6670__returns If `r` is `-1` or `1` returns `singular`, else `plural`.
6671
6672[endsect]
6673
6674[section:duration_symbol_translate Non Member Function `duration_symbol_translate()`]
6675
6676      template <class CharT>
6677      std::basic_string<CharT> duration_symbol_translate(
6678        std::basic_string<CharT> const &symbol);
6679
6680__returns `symbol`.
6681
6682[endsect]
6683[section:epoch_translate Non Member Function `epoch_translate()`]
6684
6685      template <class CharT>
6686      std::basic_string<CharT> epoch_translate(
6687        std::basic_string<CharT> const &epoch);
6688
6689__returns `epoch`.
6690
6691[endsect]
6692
6693[endsect] [/section:translate_hpp Header `<boost/chrono/io/translate.hpp>`]
6694]
6695
6696[endsect] [/section:io Chrono I/O]
6697
6698
6699[section:round Chrono Rounding Utilities]
6700[/==================================================================]
6701[section:floor_hpp Header `<boost/chrono/floor.hpp>`]
6702[/==================================================================]
6703
6704  namespace boost { namespace chrono {
6705    template <class To, class Rep, class Period>
6706    To floor(const duration<Rep, Period>& d);
6707  } }
6708
6709This function round down the given parameter.
6710
6711[endsect]
6712[/==================================================================]
6713[section:round_hpp Header `<boost/chrono/round.hpp>`]
6714[/==================================================================]
6715
6716  namespace boost { namespace chrono {
6717    template <class To, class Rep, class Period>
6718    To round(const duration<Rep, Period>& d);
6719  } }
6720
6721This function round to nearest, to even on tie the given parameter.
6722
6723
6724[endsect]
6725[/==================================================================]
6726[section:ceil_hpp Header `<boost/chrono/ceil.hpp>`]
6727[/==================================================================]
6728
6729  namespace boost { namespace chrono {
6730    template <class To, class Rep, class Period>
6731    To ceil(const duration<Rep, Period>& d);
6732  } }
6733
6734This function round up the given parameter.
6735
6736[endsect]
6737[endsect]
6738
6739
6740[section:other_clocks Other Clocks]
6741
6742[/==================================================================]
6743[section:process_cpu_clocks_hpp Header `<boost/chrono/process_cpu_clocks.hpp>`]
6744[/==================================================================]
6745
6746Knowing how long a program takes to execute is useful in both test and production environments. It is also helpful if such timing information is broken down into real (wall clock) time, CPU time spent by the user, and CPU time spent by the operating system servicing user requests.
6747
6748Process clocks don't include the time spent by the child process.
6749
6750    #define BOOST_CHRONO_HAS_PROCESS_CLOCKS
6751
6752    namespace boost { namespace chrono {
6753
6754        class process_real_cpu_clock;
6755        class process_user_cpu_clock;
6756        class process_system_cpu_clock;
6757        class process_cpu_clock;
6758
6759        template <typename Rep>
6760        struct process_times;
6761        template <class CharT, class Traits, class Rep>
6762        std::basic_ostream<CharT, Traits>&
6763        operator<<(std::basic_ostream<CharT, Traits>& os,
6764                process_times<Rep> const& rhs);
6765
6766        template <class CharT, class Traits, class Rep>
6767        std::basic_istream<CharT, Traits>&
6768        operator>>(std::basic_istream<CharT, Traits>& is,
6769                process_times<Rep> const& rhs);
6770
6771        template <class Rep>
6772        struct duration_values<process_times<Rep> >;
6773
6774        template <class CharT>
6775        struct clock_string<process_real_cpu_clock, CharT>;
6776        struct clock_string<process_user_cpu_clock, CharT>;
6777        struct clock_string<process_system_cpu_clock, CharT>;
6778        struct clock_string<process_cpu_clock, CharT>;
6779
6780    } }
6781    namespace std {
6782        template <class Rep>
6783        class numeric_limits<boost::chrono::process_times<Rep> >;
6784    }
6785
6786[section: BOOST_CHRONO_HAS_PROCESS_CLOCKS Macro `BOOST_CHRONO_HAS_PROCESS_CLOCKS `]
6787
6788This macro is defined if the platform supports process clocks.
6789
6790[endsect]
6791
6792[section:process_real_cpu_clock Class `process_real_cpu_clock`]
6793
6794__process_real_cpu_clock satisfy the __clock_req.
6795
6796__process_real_cpu_clock class provides access to the real process wall-clock steady clock, i.e. the real CPU-time clock of the calling process. The process relative current time can be obtained by calling `process_real_cpu_clock::now()`.
6797
6798        class process_real_cpu_clock {
6799        public:
6800            typedef __nanoseconds                          duration;
6801            typedef duration::rep                        rep;
6802            typedef duration::period                     period;
6803            typedef chrono::__time_point<process_real_cpu_clock>    time_point;
6804            static constexpr bool is_steady =            true;
6805
6806            static time_point now(  ) noexcept;
6807            static time_point now( system::error_code & ec );
6808        };
6809
6810
6811[endsect]
6812[section:process_user_cpu_clock Class `process_user_cpu_clock`]
6813
6814__process_user_cpu_clock satisfy the __clock_req.
6815
6816__process_user_cpu_clock class provides access to the user CPU-time steady clock of the calling process. The process relative user current time can be obtained by calling `process_user_cpu_clock::now()`.
6817
6818        class process_user_cpu_clock {
6819        public:
6820            typedef __nanoseconds                          duration;
6821            typedef duration::rep                        rep;
6822            typedef duration::period                     period;
6823            typedef chrono::__time_point<process_user_cpu_clock>    time_point;
6824            static constexpr bool is_steady =            true;
6825
6826            static time_point now(  ) noexcept;
6827            static time_point now( system::error_code & ec );
6828        };
6829
6830
6831[endsect]
6832
6833[section:process_system_cpu_clock Class `process_system_cpu_clock`]
6834
6835__process_system_cpu_clock satisfy the __clock_req.
6836
6837__process_system_cpu_clock class provides access to the system CPU-time steady clock of the calling process. The process relative system current time can be obtained by calling `process_system_cpu_clock::now()`.
6838
6839        class process_system_cpu_clock {
6840        public:
6841            typedef __nanoseconds                          duration;
6842            typedef duration::rep                        rep;
6843            typedef duration::period                     period;
6844            typedef chrono::__time_point<process_system_cpu_clock>    time_point;
6845            static constexpr bool is_steady =            true;
6846
6847            static time_point now(  ) noexcept;
6848            static time_point now( system::error_code & ec );
6849        };
6850
6851
6852[endsect]
6853
6854[section:process_cpu_clock Class `process_cpu_clock`]
6855
6856`process_cpu_clock` can be considered as a `tuple<process_real_cpu_clock, process_user_cpu_clock, process_system_cpu_clock>`.
6857
6858`process_cpu_clock` provides a thin wrapper around the operating system's process time API. For POSIX-like systems, that's the times() function, while for Windows, it's the `GetProcessTimes()` function.
6859
6860The process relative real, user and system current time can be obtained at once by calling `process_clocks::now()`.
6861
6862    class process_cpu_clock
6863    {
6864    public:
6865        typedef process_times<nanoseconds::rep> times ;
6866
6867        typedef __duration<times,  nano>                  duration;
6868        typedef duration::rep                           rep;
6869        typedef duration::period                        period;
6870        typedef chrono::__time_point<process_cpu_clock>   time_point;
6871        static constexpr bool is_steady =               true;
6872
6873        static time_point now(  ) noexcept;
6874        static time_point now( system::error_code & ec );
6875    };
6876
6877[endsect]
6878
6879[section:times Template Class `process_times`]
6880
6881This class is the representation of the `process_cpu_clock::duration` class. As such it needs to implements the arithmetic operators.
6882
6883        template <typename Rep>
6884        struct process_times : arithmetic<process_times<Rep>,
6885            multiplicative<process_times<Rep>, Rep,
6886            less_than_comparable<process_times<Rep> > > >
6887        {
6888            Rep real;    // real (i.e wall clock) time
6889            Rep user;    // user cpu time
6890            Rep system;  // system cpu time
6891
6892            times();
6893            times(
6894                process_real_cpu_clock::rep r,
6895                process_user_cpu_clock::rep u,
6896                process_system_cpu_clock::rep s);
6897
6898            template <typename Rep2>
6899            explicit process_times(
6900                Rep2 r);
6901            template <typename Rep2>
6902            explicit process_times(
6903                process_times<Rep2> const& rhs);
6904            operator rep() const;
6905
6906            bool operator==(process_times const& rhs);
6907            template <typename Rep2>
6908            bool operator==(process_times<Rep2> const& rhs);
6909
6910            times operator+=(process_times const& rhs);
6911            times operator-=(process_times const& rhs);
6912            times operator*=(process_times const& rhs);
6913            times operator/=(process_times const& rhs);
6914            bool operator<(process_times const & rhs) const;
6915        };
6916
6917[endsect]
6918
6919[section:times_io `process_times` Input/Output]
6920
6921    template <class CharT, class Traits, class Rep>
6922    std::basic_ostream<CharT, Traits>&
6923    operator<<(std::basic_ostream<CharT, Traits>& os,
6924            process_times<Rep> const& rhs);
6925
6926__effects Output each part separated by ';' and surrounded by '{', '}'.
6927
6928__throws None.
6929
6930    template <class CharT, class Traits, class Rep>
6931    std::basic_istream<CharT, Traits>&
6932    operator>>(std::basic_istream<CharT, Traits>& is,
6933            process_times<Rep> const& rhs);
6934
6935__effects overrides the value of rhs if the input stream has the format "{r;u;s}". Otherwise, set the input stream state as failbit | eofbit.
6936
6937__throws None.
6938
6939
6940[endsect]
6941
6942[section:times_duration_values `duration_values` Specialization for `process_times<>`]
6943
6944    template <class Rep>
6945    struct __duration_values<process_times<Rep> >
6946    {
6947        static process_times<Rep> zero();
6948        static process_times<Rep> max();
6949        static process_times<Rep> min();
6950    };
6951
6952The `times` specific functions `zero()`, `max()` and `min()` uses the relative functions on the representation of each component.
6953
6954[endsect]
6955
6956[section:clock_string_process_real_cpu_clock `clock_string<process_real_cpu_clock>` Specialization]
6957
6958    template <class CharT>
6959    struct clock_string<process_real_cpu_clock, CharT>
6960    {
6961        static std::basic_string<CharT> name();
6962        static std::basic_string<CharT> since();
6963    };
6964
6965`clock_string<>::name()` returns "process_real_cpu_clock".
6966
6967`clock_string<>::since()` returns " since process start-up"
6968
6969[endsect]
6970
6971[section:clock_string_process_user_cpu_clock `clock_string<process_user_cpu_clock>` Specialization]
6972
6973    template <class CharT>
6974    struct clock_string<process_user_cpu_clock, CharT>
6975    {
6976        static std::basic_string<CharT> name();
6977        static std::basic_string<CharT> since();
6978    };
6979
6980`clock_string<>::name()` returns "process_user_cpu_clock".
6981
6982`clock_string<>::since()` returns " since process start-up"
6983
6984
6985[endsect]
6986
6987[section:clock_string_process_system_cpu_clock `clock_string<process_system_cpu_clock>` Specialization]
6988
6989    template <class CharT>
6990    struct clock_string<process_system_cpu_clock, CharT>
6991    {
6992        static std::basic_string<CharT> name();
6993        static std::basic_string<CharT> since();
6994    };
6995
6996`clock_string<>::name()` returns "process_system_cpu_clock".
6997
6998`clock_string<>::since()` returns " since process start-up"
6999
7000
7001[endsect]
7002
7003[section:clock_string_process_cpu_clock `clock_string<process_cpu_clock>` Specialization]
7004
7005    template <class CharT>
7006    struct clock_string<process_cpu_clock, CharT>
7007    {
7008        static std::basic_string<CharT> name();
7009        static std::basic_string<CharT> since();
7010    };
7011
7012`clock_string<>::name()` returns "process_cpu_clock".
7013
7014`clock_string<>::since()` returns " since process start-up"
7015
7016[endsect]
7017
7018[section:times_numeric_limits `numeric_limits` Specialization for `process_times<>`]
7019
7020    namespace std {
7021        template <>
7022        class numeric_limits<boost::chrono::process_times<Rep>> {
7023            typedef boost::chrono::process_times<Rep> Res;
7024
7025        public:
7026            static const bool is_specialized = true;
7027            static Res min();
7028            static Res max();
7029            static Res lowest();
7030            static const int digits;
7031            static const int digits10;
7032            static const bool is_signed = false;
7033            static const bool is_integer = true;
7034            static const bool is_exact = true;
7035            static const int radix = 0;
7036        };
7037    }
7038
7039The `process_times<Rep>` specialization functions `min()`, `max()` and `lowest()` uses the relative functions on the representation of each component.
7040
7041Notes
7042
7043* `min()` returns the tuple of mins.
7044* `max()` returns the tuple of maxs.
7045* `lowest()` returns the tuple of lowests.
7046* `digits` is the sum of (binary) digits.
7047* `digits10` is the sum of digits10s.
7048
7049[endsect]
7050
7051[endsect]
7052
7053[/==================================================================]
7054[section:thread_clock_hpp Header `<boost/chrono/thread_clock.hpp>`]
7055[/==================================================================]
7056
7057Knowing the time a thread takes to execute is useful in both test and production environments.
7058
7059    #define BOOST_CHRONO_HAS_THREAD_CLOCK
7060    #define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY
7061    namespace boost { namespace chrono {
7062
7063        class thread_clock;
7064        template <class CharT>
7065        struct clock_string<thread_clock, CharT>;
7066
7067    } }
7068
7069[section:BOOST_CHRONO_HAS_THREAD_CLOCK Macro `BOOST_CHRONO_HAS_THREAD_CLOCK`]
7070
7071This macro is defined if the platform supports thread clocks.
7072
7073[endsect]
7074
7075[section:BOOST_CHRONO_THREAD_CLOCK_IS_STEADY Macro `BOOST_CHRONO_THREAD_CLOCK_IS_STEADY`]
7076
7077This macro is defined if the platform has a thread clock. Its value is true if it is steady and false otherwise.
7078
7079[endsect]
7080
7081[section:thread_clock Class `thread_clock`]
7082
7083__thread_clock satisfy the __clock_req.
7084
7085__thread_clock class provides access to the real thread wall-clock, i.e. the real CPU-time clock of the calling thread. The thread relative current time can be obtained by calling `thread_clock::now()`.
7086
7087        class thread_clock {
7088        public:
7089            typedef __nanoseconds                          duration;
7090            typedef duration::rep                        rep;
7091            typedef duration::period                     period;
7092            typedef chrono::__time_point<thread_clock>     time_point;
7093            static constexpr bool is_steady =            BOOST_CHRONO_THREAD_CLOCK_IS_STEADY;
7094
7095            static time_point now(  ) noexcept;
7096            static time_point now( system::error_code & ec );
7097        };
7098
7099
7100[endsect]
7101
7102
7103[section:clock_string_thread_clock `clock_string<thread_clock>` Specialization]
7104
7105    #if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
7106    template <class CharT>
7107    struct clock_string<thread_clock, CharT>
7108    {
7109        static std::basic_string<CharT> name();
7110        static std::basic_string<CharT> since();
7111    };
7112    #endif
7113
7114`clock_string<>::name()` returns "thread_clock".
7115
7116`clock_string<>::since()` returns " since thread start-up"
7117
7118
7119[endsect]
7120
7121[endsect]
7122
7123[endsect]
7124
7125[endsect]
7126
7127[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7128[/=================]
7129[section Appendices]
7130[/=================]
7131
7132[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7133[/==================================]
7134[section:history Appendix: History]
7135[/==================================]
7136
7137[section [*Version 2.0.8, , 2018 - 1.70] ]
7138
7139[*Fixes:]
7140
7141* Remove Stopwatches, which was never be delivered officially.
7142
7143[endsect] [/section [*Version 2.0.7] ]
7144
7145[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7146[section [*Version 2.0.7, August 18, 2016 - 1.62] ]
7147
7148[*Fixes:]
7149
7150* [@http://svn.boost.org/trac/boost/ticket/11630 #11630] boost chrono documentation about boost chrono version & io API is wrong.
7151* [@http://svn.boost.org/trac/boost/ticket/12176 #12176] Chrono without linking to Boost.System
7152* [@http://svn.boost.org/trac/boost/ticket/12260 #12260] Bug: time_fmt does not support for wchar_t on windows
7153
7154[endsect] [/section [*Version 2.0.7] ]
7155[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7156[section [*Version 2.0.6, December 18, 2015 - 1.60] ]
7157
7158[*Fixes:]
7159
7160* [@http://svn.boost.org/trac/boost/ticket/11330 #11330] boost::chrono::duration default constructor doesn't initialize rep_
7161* [@http://svn.boost.org/trac/boost/ticket/11618 #11618] Chrono IO V2 doc ios_state.hpp does not exist
7162* [@http://svn.boost.org/trac/boost/ticket/11631 #11631] boost chrono io v2 does not let you support custom clocks
7163
7164[endsect] [/section [*Version 2.0.6] ]
7165[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7166[section [*Version 2.0.5, February 18, 2015 - 1.58] ]
7167
7168[*Fixes:]
7169
7170* [@http://svn.boost.org/trac/boost/ticket/10778 #10778]	VC14 CTP4 Atomic don't compile with boost::chrono durations which are not TriviallyCopyable
7171* [@http://svn.boost.org/trac/boost/ticket/10840 #10840] 	Missing std:: qualifier for puts call in test_7868.cpp
7172* [@http://svn.boost.org/trac/boost/ticket/10851 #10851] 	Missing std:: qualifier for puts call in time_point_output.cpp
7173* [@http://svn.boost.org/trac/boost/ticket/10893 #10893] 	Minor doc typo in Boost.Chrono
7174* [@http://svn.boost.org/trac/boost/ticket/10992 #10992] 	Chrono IO state savers inconsistent with Boost.IO state savers
7175* [@http://svn.boost.org/trac/boost/ticket/10995 #10995] 	duration_put::put_value truncates fractional part
7176* [@http://svn.boost.org/trac/boost/ticket/11006 #11006] 	Impossible to instantiate time_fmt_io_saver due to several errors.
7177* [@http://svn.boost.org/trac/boost/ticket/11012 #11012] 	chrono_io v2 fail to compile with boost::chrono::duration< boost::rational<int> >
7178
7179[endsect] [/section [*Version 2.0.5] ]
7180[section [*Version 2.0.4, July 12, 2014 - 1.56] ]
7181
7182[*Fixes:]
7183
7184* [@http://svn.boost.org/trac/boost/ticket/6918 #6918] Boost Chrono compilation failure on HP uX due to undefined pthread_getcpuclockid
7185* [@http://svn.boost.org/trac/boost/ticket/8006 #8006] Boost::Chrono Assertion at startup - steady_clock::now() - Windows
7186
7187* [@http://svn.boost.org/trac/boost/ticket/9337 #9337] chrono::process_cpu_clock time points wrong by factor 1000 on Linux
7188* [@http://svn.boost.org/trac/boost/ticket/9342 #9342] Regression on process_cpu_clock::timepoint io on V2
7189* [@http://svn.boost.org/trac/boost/ticket/9419 #9419] boost::chrono::floor()/round() and negative durations is wrong
7190* [@http://svn.boost.org/trac/boost/ticket/9698 #9698] boost::chrono::thread_clock not declared in OSX
7191* [@http://svn.boost.org/trac/boost/ticket/9720 #9720] boost::this_thread::sleep_for() sometimes returns immediately on win32
7192* [@http://svn.boost.org/trac/boost/ticket/9859 #9859] Remove references to gcc-mingw
7193* [@http://svn.boost.org/trac/boost/ticket/9918 #9918] chrono compilation error on Solaris, function timegm
7194* [@http://svn.boost.org/trac/boost/ticket/9811 #9811] boost/boost/chrono/duration.hpp:355:56: error: call to non-constexpr function 'static std::numeric_limits<float>::_Ty std::numeric_limits<float>::max()' /home/zosun/input_service/inputservices-core-service/other/boost/boost/chrono/duration.hpp: In static member function 'static constexpr double boost::chrono::detail::chrono_numeric_limits<double, true>::lowest()':
7195* [@http://svn.boost.org/trac/boost/ticket/10069 #10069] Overflow in chrono clocks on 32bit
7196* [@http://svn.boost.org/trac/boost/ticket/10151 #10151] timegm function not available on QNX
7197
7198[endsect] [/section [*Version 2.0.4] ]
7199
7200[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7201[section [*Version 2.0.3, September 29, 2013 - 1.55] ]
7202
7203[*Fixes:]
7204
7205* [@http://svn.boost.org/trac/boost/ticket/7868 #7868] chrono_io parses time incorrectly (1.53 and 1.52)
7206* [@http://svn.boost.org/trac/boost/ticket/9028 #9028] Typo in boost/chrono/stopwatches/formatters/base_formatter.hpp
7207* [@http://svn.boost.org/trac/boost/ticket/9147 #9147] uninitialized std::tm
7208* [@http://svn.boost.org/trac/boost/ticket/9274 #9274] lost of precision on system_clock input.
7209* [@http://svn.boost.org/trac/boost/ticket/9276 #9276] output from a system_clock::time_point get a time_point that is one day later than expected.
7210
7211[endsect] [/section [*Version 2.0.3] ]
7212
7213[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7214[section [*Version 2.0.2, June 15, 2013 - 1.54] ]
7215
7216
7217[*Fixes:]
7218
7219* [@http://svn.boost.org/trac/boost/ticket/8079 #8079] Chrono memory leak
7220* [@http://svn.boost.org/trac/boost/ticket/8318 #8318] BOOST_FORCEINLINE constructors of time_point and duration
7221* [@http://svn.boost.org/trac/boost/ticket/8367 #8367] chrono does not compile with clang from XCode 4.5.2 with -std=c++11 -stdlib=libc++ and -arch armv7
7222* [@http://svn.boost.org/trac/boost/ticket/8370 #8370] typo in chrono reference
7223* [@http://svn.boost.org/trac/boost/ticket/8435 #8435] Can't compile Chrono on HP-UX due to no CLOCK_REALTIME macro.
7224* [@http://svn.boost.org/trac/boost/ticket/8690 #8690] duration_units_default - lost return types constness in overridden methods.
7225* [@http://svn.boost.org/trac/boost/ticket/8691 #8691] iostate is not checked after scan_keyword call.
7226* [@http://svn.boost.org/trac/boost/ticket/8696 #8696] chrono compilation error on Solaris/gcc.
7227
7228[endsect] [/section [*Version 2.0.2] ]
7229
7230[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7231[section [*Version 2.0.1, January 18, 2013 - 1.53] ]
7232
7233[*Deprecated:]
7234
7235* The chrono i/o version included in Boost.Chrono 1.2.x has been completly refactored in version 2.0.0
7236* chrono I/O: The manipulators __duration_short, __duration_long are deprecated. You should use the parameterized form __duration_fmt or the renamed manipulators __duration_symbol and __duration_prefix  instead.
7237* chrono I/O: The __duration_punct<> facet is deprecated. You should use the __get_duration_style free function to get the informations and use the __duration_units facet for localization purposes.
7238
7239When BOOST_CHRONO_VERSION==2 the preceding deprecated functions are not available.
7240
7241[*Fixes:]
7242
7243* [@http://svn.boost.org/trac/boost/ticket/7546 #7546] time_point<system_clock> output version 2 fails to compile  assigned  viboes  Bugs  Boost 1.53.0  --
7244* [@http://svn.boost.org/trac/boost/ticket/7547 #7547] time_point<system_clock> input version 2 fails to compile   assigned  viboes  Bugs  Boost 1.53.0  --
7245* [@http://svn.boost.org/trac/boost/ticket/7868 #7868] chrono_io parses time incorrectly (1.53 and 1.52)
7246
7247
7248[endsect] [/section [*Version 2.0.1] ]
7249
7250[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7251[section [*Version 2.0.0, October 23, 2012 - 1.52] ]
7252
7253[*New Features:]
7254
7255* Enhance chrono I/O
7256    * [@http://svn.boost.org/trac/boost/ticket/5980 #5980] Enhance chrono I/O with H. Hinnant proposal [@http://home.roadrunner.com/~hinnant/bloomington/chrono_io.html proposal] which has the advantage to provide I/O for system clocks using the Gregorian Calendar.
7257    * [@http://svn.boost.org/trac/boost/ticket/5981 #5981] Add i/o state savers for duration and time_point formatting state.
7258    * [@http://svn.boost.org/trac/boost/ticket/7059 #7059] Add low level i/o facilities.
7259
7260[*Deprecated:]
7261
7262* The chrono i/o version included in Boost.Chrono 1.2.x has been completly refactored in version 2.0.0
7263* chrono I/O: The manipulators __duration_short, __duration_long are deprecated. You should use the parameterized form __duration_fmt or the renamed manipulators __duration_symbol and __duration_prefix  instead.
7264* chrono I/O: The __duration_punct<> facet is deprecated. You should use the __get_duration_style free function to get the informations and use the __duration_units facet for localization purposes.
7265
7266When BOOST_CHRONO_VERSION==2 the preceding deprecated functions are not available.
7267
7268[*Fixes:]
7269
7270* [@http://svn.boost.org/trac/boost/ticket/7381 #7381] C++11 compliance: unresolved symbol when assigning a constexpr duration to a non-const local variable.
7271* [@http://svn.boost.org/trac/boost/ticket/7479 #7479] Compiles fails with compilers supporting constexpr fails if the standard library doesn't provides the constexpr interface
7272* [@http://svn.boost.org/trac/boost/ticket/7493 #7493] compile fail on intel-linux-12.1.3.0x because of bug on explicit bool conversion
7273* [@http://svn.boost.org/trac/boost/ticket/7542 #7542] Missing -lpthread in chrono/io tester Sandia-clang-trunk
7274
7275[*Would not fix:]
7276
7277* [@http://svn.boost.org/trac/boost/ticket/6871 #6871] chrono_io.hpp: operator<<(ostream& os, ...) modifies the state of os.
7278
7279  * The new io interface provided in version 2 solves this issue. You should move to the new version.
7280
7281[*Known bugs not fixed yet:]
7282
7283* [@http://svn.boost.org/trac/boost/ticket/7525 #7525] Wrong clock_string<system_clock>::since() on Windows
7284
7285[/warning
7286
7287The time_point<system_clock,D> formatter/parser specializations don't work yet. It has been disable defining `BOOST_CHRONO_DONT_PROVIDE_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT` until a fix for the following ticket is found:
7288
7289- [@http://svn.boost.org/trac/boost/ticket/7547 #7547] time_point<system_clock> input version 2 fails to compile
7290
7291- [@http://svn.boost.org/trac/boost/ticket/7546 #7546] time_point<system_clock> output version 2 fails to compile
7292
7293In this case the io operators behave like any time_point as if the specialization was removed.
7294
7295In order to enable this features on compilers working with, you will need to define `BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT`.
7296
7297]
7298
7299[endsect] [/section [*Version 2.0.0] ]
7300
7301[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7302[section [*Version 1.2.3, August 1, 2012 - 1.51] ]
7303
7304[*Fixes:]
7305
7306* [@http://svn.boost.org/trac/boost/ticket/6918 #6918] Boost Chrono compilation failure on HP uX due to undefined pthread_getcpuclockid.
7307* [@http://svn.boost.org/trac/boost/ticket/6241 #6241] boost::chrono compilation problems without std::wstring support.
7308* [@http://svn.boost.org/trac/boost/ticket/6987 #6987] Documentation & C++11.
7309* [@http://svn.boost.org/trac/boost/ticket/7041 #7041] time_point.hpp depends on Boost.System.
7310* [@http://svn.boost.org/trac/boost/ticket/7042 #7042] Avoiding time_point and duration dependency on time.h and CLOCK_REALTIME.
7311* [@http://svn.boost.org/trac/boost/ticket/7058 #7058] Make it work when BOOST_NO_EXCEPTIONS is defined.
7312* [@http://svn.boost.org/trac/boost/ticket/7069 #7069] Misspellings in clock_string<thread_clock>.
7313* [@http://svn.boost.org/trac/boost/ticket/7081 #7081] WinError.h capitalization in boost/detail/win/basic_types.hpp.
7314
7315[endsect] [/section [*Version 1.2.3] ]
7316
7317[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
7318[section [*Version 1.2.2, April 1, 2012 - 1.50] ]
7319
7320[*Fixes:]
7321
7322* [@http://svn.boost.org/trac/boost/ticket/6361 #6361] integer overflow in boost::chrono::process_real_cpu_clock::now() under Windows 32bits.
7323* [@http://svn.boost.org/trac/boost/ticket/6628 #6628] compiler warning in process_cpu_clocks.hpp.
7324* [@http://svn.boost.org/trac/boost/ticket/6666 #6666] thread_clock.hpp needs pthread.h.
7325
7326[endsect] [/section [*Version 1.2.2] ]
7327
7328[section [*Version 1.2.1, February 1, 2012 - 1.49] ]
7329
7330[*Fixes:]
7331
7332* [@http://svn.boost.org/trac/boost/ticket/6092 #6092] Input from non integral durations makes the compiler fail.
7333* [@http://svn.boost.org/trac/boost/ticket/6093 #6093] [1/3]second fails as valid duration input.
7334* [@http://svn.boost.org/trac/boost/ticket/6113 #6113] duplicate symbol when BOOST_CHRONO_HEADER_ONLY is defined.
7335* [@http://svn.boost.org/trac/boost/ticket/6243 #6243] Sandia-pgi-11.9: more than one instance of overloaded function "min" matches.
7336* [@http://svn.boost.org/trac/boost/ticket/6257 #6257] process_cpu_clock::now() on linux gives time_points 1/1000 times.
7337
7338[endsect] [/section [*Version 1.2.1] ]
7339
7340
7341[section [*Version 1.2.0, October 17, 2011] ]
7342[*New Features:]
7343
7344* [@http://svn.boost.org/trac/boost/ticket/5979 #5979] Added chrono rounding utilities as defined By Howard Hinnant [@http://home.roadrunner.com/~hinnant/duration_io/chrono_util.html here].
7345* [@http://svn.boost.org/trac/boost/ticket/5978 #5978] Added BOOST_CHRONO_HAS_PROCESS_CLOCKS to know if process clocks are available.
7346* [@http://svn.boost.org/trac/boost/ticket/5998 #5998] Make possible to don't provide hybrid error handling.
7347* [@http://svn.boost.org/trac/boost/ticket/5906 #5906] Take in account the constexpr as defined in the standard.
7348* [@http://svn.boost.org/trac/boost/ticket/5907 #5907] Take in account noexcept for compilers supporting it.
7349
7350[*Fixes:]
7351
7352* [@http://svn.boost.org/trac/boost/ticket/2114 #2114] Enable visibility support (Boost.Chorno part)
7353* [@http://svn.boost.org/trac/boost/ticket/5669 #5669] Intel compiler failure to compile duration.hpp
7354* [@http://svn.boost.org/trac/boost/ticket/5909 #5909] process_cpu_clock::now() on MAC gives time_points 1/1000 times.
7355* [@http://svn.boost.org/trac/boost/ticket/5946 #5946] Process real cpu clock returns the system steady clock (windows).
7356* [@http://svn.boost.org/trac/boost/ticket/5974 #5974] Process real cpu clock should use clock() instead of times() in MAC which is twice faster and have better resolution.
7357
7358[*Cleanup:]
7359
7360* [@http://svn.boost.org/trac/boost/ticket/5975 #5975] Reduce the combinations of header-only, shared, static link to reduce test time by 50%.
7361* [@http://svn.boost.org/trac/boost/ticket/5976 #5976] chrono_accuracy_test is not deterministic and should be removed from the regression tests
7362* [@http://svn.boost.org/trac/boost/ticket/5977 #5977] Remove old files from Beman's version. Some old files included in the Beman's version and not documented in the reviewed version that have been definitely removed from the repository as
7363  * boost/chrono/timer.hpp,
7364  * boost/chrono/process_times.hpp
7365  * boost/chrono/detail/process_clock.hpp,
7366  * boost/chrono/detail/mac/process_clock.hpp,
7367  * boost/chrono/detail/posix/process_clock.hpp,
7368  * boost/chrono/detail/win/process_clock.hpp,
7369  * boost/chrono/detail/run_timer.hpp,
7370  * boost/chrono/detail/run_timer_static.hpp,
7371
7372
7373
7374[endsect] [/section [*Version 1.2.0] ]
7375
7376
7377[section [*Version 1.1.0, Mars 17, 2011] ]
7378
7379[*New Features:]
7380
7381* [@http://svn.boost.org/trac/boost/ticket/???? #????] Added time_point unary operators +,-,++,-- and binary operators +=,-= with Rep al RHS.
7382* [@http://svn.boost.org/trac/boost/ticket/5323 #5323] Add Associated type difference_type for chrono::time_point.
7383
7384[*Fixes:]
7385
7386* [@http://svn.boost.org/trac/boost/ticket/5322 #5322] Explicit default constructed chrono::durations are uninitialized
7387
7388
7389[endsect] [/section [*Version 1.1.0] ]
7390
7391[section [*Version 1.0.0, January 6, 2011] ]
7392
7393* Moved chrono to trunk taking in account the review remarks.
7394* Documentation revision.
7395
7396[*Features:]
7397
7398* Boost_Chrono is now a configurable header-only library version (that also allows the user to choose if the `windows.h` file is included or not).
7399* Added clock_string<> traits.
7400* Define chrono-io for all the clocks.
7401* Add input of process_times representation.
7402
7403[*Implementation:]
7404
7405* Use of detail/win files to avoid the use of windows.h file.
7406* Completed the error_code handling.
7407* Works now with BOOST_SYSTEM_NO_DEPRECATED.
7408
7409[*Fixes:]
7410
7411* Fix some warnings.
7412* Fix original errors on Mac
7413* Don't fix the link with boost_system to static.
7414
7415[*Test:]
7416
7417* Added test on process and thread clocks.
7418* Moved to lightweight_test.hpp.
7419* Able to test multiple configurations.
7420
7421[*Doc:]
7422
7423* Removed some not useful parts as the test and the tickets.
7424
7425[endsect] [/section [*Version 1.0.0] ]
7426
7427[/
7428[section [*Version 0.6.0, September 22, 2010] ]
7429
7430[*Features:]
7431
7432* Added experimental chrono_io.
7433
7434[*Fixes:]
7435
7436* Fix duration values min implementation.
7437* Fix some warnings
7438
7439[*Test:]
7440
7441* Adapted test from libc++/chrono
7442
7443[endsect]
7444
7445[section [*Version 0.5.0, September 10, 2010] ]
7446
7447[*Features:]
7448
7449* Stopwatches, Ratio and CommonType have been moved to separated libraries: Boost.Stopwatches, Boost.Ratio and Boost.TypeTraits.
7450
7451[endsect]
7452
7453[section [*Version 0.4.7, September 1, 2010] ]
7454
7455[*New Features:]
7456
7457* Added __lightweight_stopwatch__.
7458
7459[endsect]
7460
7461[section [*Version 0.4.6, August 28, 2010] ]
7462
7463[*New Features:]
7464
7465* Implementation of __common_type without using Boost.TypeOf.
7466* Added __stopwatch_accumulator_time_formatter__ class.
7467
7468[*Old Features:]
7469
7470* Type reporter removed from Stopwatches as well as the get_reporter metafunction.
7471
7472[*Bug Fixes]
7473
7474* __process_cpu_clock is now a valid model of __Clock that can be used with __stopclocks_accumulator__.
7475* eliminate or suppress a lot of warnings appearing with warnings=all -Wextra
7476* improve the error code handling
7477
7478[endsect]
7479
7480[section [*Version 0.4.5, July 6, 2010] ['Documentation update]]
7481
7482[*Documentation]
7483
7484* Overview rewriting
7485* Added missing __thread_clock reference.
7486* How to implement a __thread_clock tutorial removed.
7487* References section renamed to External Resources.
7488* Added links to source examples.
7489* Added links between Models and Concepts.
7490* Added macros descriptions.
7491* Cleanup.
7492
7493[*Bug Fixes]
7494
7495* Valgrind fixes: "Conditional jump or move depends on uninitialised value(s)"
7496* Take care of Boost.System break on version 1.44
7497* gcc.4.4 "warning: suggest parentheses around '&&' within '||' " removal.
7498
7499[endsect]
7500
7501[section [*Version 0.4.4, February 22, 2010] [' Warning fixes]]
7502
7503[*Bug Fixes]
7504
7505* `scoped_suspend` warning removal
7506* `error_code` management completed
7507
7508[endsect]
7509
7510[section [*Version 0.4.3, June 18, 2010] ['Missing file fixe]]
7511
7512[*Bug Fixes]
7513
7514* boost/thread/detail/cv_status.hpp file was not committed.
7515
7516[endsect]
7517
7518[section [*Version 0.4.2, June 18, 2010] ['Packaging fixe]]
7519
7520* Boost.Conversion library, used by Boost.Thread porting to Boost.Chrono was not packaged.
7521
7522[endsect]
7523
7524[section [*Version 0.4.1, June 17, 2010] ['Added thread clock implementation on Windows]]
7525
7526[*New Features:]
7527
7528* Added __thread_clock implementation on Windows.
7529* Added *Boost.Thread* using *Boost.Chrono*.
7530
7531[endsect]
7532
7533[section [*Version 0.4, February 28, 2010] ['New thread clock and Suspendible clock ]]
7534
7535[*New Features:]
7536
7537* __SuspendibleClock__ concept + template class _suspendible_clock__.
7538* Added `scope_suspend` which do `suspend`/`resume` if the __Clock is a model of __SuspendibleClock__ concept, and nothing otherwise.
7539* __thread_clock support on platforms providing it natively.
7540* Added support for wide character for __stopwatch_reporter, `stopclock`, and `stopclock_accumulator`.
7541* `digital_time` renamed `t24_hours`.
7542
7543[*Perf]
7544
7545Added performances measures.
7546
7547[*Bug Fixes]
7548
7549* Bug on timeval_demo.
7550
7551    time_point t(duration(xtime(0)));  // this was taken as a function declaration
7552    gettimeofday((timeval*)&t, 0);
7553    return t;
7554by
7555
7556    timeval tv;
7557    gettimeofday(&tv, 0);
7558    xtime xt( tv.tv_sec, tv.tv_usec);
7559    return time_point(duration(xt));
7560
7561* Bug on run_timer_test (add a global variable to avoid optimization that removes completely the code to be  measured
7562
7563[endsect]
7564
7565[section [*Version 0.3.2, January 25, 2010] ['New frequency, lifetime and percentage stopwatch_accumulator features]]
7566[*Features:]
7567
7568* Added overloading for `operator/(Integer/Duration)`
7569* Added frequency, lifetime and percentage to the default `stopwatch_accumulator_formatter`.
7570
7571[*Bug Fixes]
7572* Specific formatters didn't work completely.
7573* Replace `duration(0)` by `duration::zero()` on template classes.
7574* `suspend` doesn't works: `partial_` not initialized neither taken in account by the elapsed function.
7575
7576[endsect]
7577
7578[section [*Version 0.3.1, January 20, 2010] ['New support for wide characters]]
7579[*Features:]
7580
7581* Support for wide characters on formatters and stopclocks
7582* added `chrono.hpp` and `stopwatches.hpp` at the boost level
7583
7584
7585[endsect]
7586
7587[section [*Version 0.3.0, January 17, 2010] ['New stopwatch/stopclock feature + Bug fixes]]
7588[*Features:]
7589
7590* Added independent process cpu clocks for real, user, system process CPU time
7591* Added global process cpu clock for real, user, system process CPU time
7592* Added `digital_time` (looking for a better name)
7593* Added new __Stopwatch__ concept measuring elapsed time between different points in time associated to the operations `start`, `stop`, `suspend` and `resume`.
7594* Added __stopwatch__ is a model __Stopwatch__ measuring the elapsed time between the `start` and the `stop` operations.
7595* Added __laps_stopwatch is a model __Stopwatch__ allowing to accumulate several time samples and gives the average, ...
7596* Added scoped helper classes allowing to pairwise `start`/`stop` operations, `suspend`/`resume` and `resume`/`suspend` a __Stopwatch__.
7597* Added new stopwatch __Formatter__ concept
7598    * Added stopwatch formatter "%ds\\n"
7599    * Added stopwatch accumulator formatter "%c times, sum=%ss, min=%ms, max=%Ms, mean=%as\\n"
7600    * Added time formatter "real %rs, cpu %cs (%p%), user %us, system %ss\\n"
7601    * Added digital_time formatter "%d days(s) %h:%m:%s.%n\\n"
7602* __stopwatch_reporter is a convenient generic class reporting elapsed time for the Stopwatch concept.
7603* Added `stopclock<__Clock>` shortcut `stopwatch_reporter<stopwatch<__Clock>>`
7604* Added __scoped_stopclock__ which trace at the constructor and destructor.
7605* Added `typeof` registration for classes __duration and __time_point
7606
7607* The old classes `process_times`, `process_clock`, `process_timer`, `timer` and `run_timer` are deprecated as the preceding additions are more generic. However for backward compatibility they preserved until inclusion of the library in Boost. Next follows the equivalences:
7608    * `timer<>` ~ `stopwatch<>`
7609    * `process_timer` ~ `stopwatch<process_cpu_clock>`
7610    * `run_timer` ~ `stopclock<>`
7611
7612[*Bug Fixes]
7613
7614* Try to correct warning "C4251: 'boost::chrono::run_timer::m_format' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'boost::chrono::run_timer'", by don't including inline functions using the std::string `m_format`.
7615
7616[endsect]
7617
7618[section [*Version 0.2.1, December 13, 2009] ['Bug fixes]]
7619
7620[*Bug Fixes]
7621
7622* Replace `INTMAX_C` by `BOOST_INTMAX_C` until `boost/cstdint.hpp` ensures `INTMAX_C` is always defined.
7623* Define __BOOST_CHRONO_HAS_CLOCK_STEADY__ when `BOOST_CHRONO_WINDOWS_API`
7624* Commenting invalid operator declarations
7625* Take care of Boost `min`/`max` recommendations
7626* Complete qualification when defining nested typedef duration on clocks to avoid the following compile error:
7627
7628    ./boost/chrono/chrono.hpp:945: error: declaration of 'typedef class boost::chrono::duration<long long int, boost::__ratio<1ll, 10000000ll> > boost::chrono::system_clock::duration'
7629    ./boost/chrono/chrono.hpp:458: error: changes meaning of 'duration' from 'class boost::chrono::duration<long long int, boost::__ratio<1ll, 10000000ll> >'
7630
7631* cleanup of simulated...
7632* warning removal on `posix/process_clock.cpp`.
7633* disable VC++ foolishness.
7634* Update Jamfiles to manage with dll.
7635* removal of conversion warning in test_duration.
7636* manage with MSVC reporting a warning instead of an error when there is an integral constant overflow.
7637* Use `STATIC_ASSERT` specific macro to solve the compile failing issue.
7638* Qualify with `boost::detail` `boost::chrono::detail` to avoid ambiguities with MSVC.
7639
7640
7641[*Documentation:]
7642
7643More updated documentation.
7644
7645[endsect]
7646
7647[section [*Version 0.2.0, December 8, 2009] ['+ Features + Bug fixes + Updated documentation]]
7648
7649[*Features:]
7650
7651* Added __ratio construction and assignment from an equivalent __ratio ([@http://home.roadrunner.com/~hinnant/issue_review/lwg-active.html#1281 [*LWG 1281. CopyConstruction and Assignment between ratios having the same normalized form]])
7652* Added nested __ratio typedef type ([@http://home.roadrunner.com/~hinnant/issue_review/lwg-active.html#1281 [*LWG 1281. CopyConstruction and Assignment between ratios having the same normalized form]])
7653* Added __BOOST_CHRONO_HAS_CLOCK_STEADY__ macro to state if __steady_clock is provided on this platform.
7654* Added __duration `operator%` ([@http://home.roadrunner.com/~hinnant/issue_review/lwg-defects.html#934 [*LGW 934. duration is missing operator%]])
7655* Added constexpr when constexpr should be used.
7656* Complete __duration `operator*` and `operator/`.
7657
7658
7659[*Implementation:]
7660
7661* Use `INTMAC_C` to name `intmax_t` constants instead of `LL`.
7662* Separate `chrono.cpp` on # files `win/chrono.cpp`, `mac/chrono.cpp` and `posix/chrono.cpp` to make easier the maintenance on different platforms.
7663* Separate `process_clock.cpp` on # files `win/process_clock.cpp`, `mac/process_clock.cpp` and `posix/process_clock.cpp` to make easier the maintenance on different platforms.
7664* Added the `error_code` prototype for `steady_clock::now` for `mac/chrono.cpp`.
7665* Fully implement `mac/chrono.cpp` with error handling.
7666* Take care on POSIX systems when `CLOCK_STEADY` is not defined.
7667
7668[*Documentation:]
7669
7670* The documentation is written now using quick-book using as base [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm [*N2661 - A Foundation to Sleep On]] .
7671
7672[*Bug Fixes]
7673
7674* `operator/` was ambiguous: Disambiguate duration `operator/`.
7675* `CLOCK_STEADY` is not defined with cygwin/gcc 3.4: Disable code when __BOOST_CHRONO_HAS_CLOCK_STEADY__ is not defined.
7676* result of metafunctions `ratio_multiply` and `ratio_divide` were not normalized ratios: Use of the nested __ratio typedef type on __ratio arithmetic operations.
7677* Copy constructor from similar __duration masked the defaulted operations: Added duration defaulted implementations
7678
7679
7680[endsect]
7681[section [*Version 0.1.0, April 29, 2009] ['Beman's boostified version Chrono]]
7682
7683[*Features:]
7684
7685*  The C++11 Standard Library's __common_type.
7686*  The C++11 Standard Library's compile-time rational arithmetic.
7687*  The C++11 Standard Library's time utilities, including:
7688    * Class template __duration
7689    * Class template __time_point
7690    * Clocks:
7691        * __system_clock
7692        * __steady_clock
7693        * `high_resolution_clock`
7694
7695* Class template timer, with typedefs:
7696    * `system_timer`
7697    * `steady_timer`
7698    * `high_resolution_timer`
7699
7700* Process clocks and timers:
7701    * `process_clock`, capturing real, user-CPU, and system-CPU times.
7702    * `process_timer`, capturing elapsed real, user-CPU, and system-CPU times.
7703    * `run_timer`, convenient reporting of process_timer results.
7704
7705
7706[endsect]
7707]
7708[endsect]
7709
7710[/======================================]
7711[section:rationale Appendix: Rationale]
7712
7713See [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm [*N2661 - A Foundation to Sleep On]] which is very informative and provides motivation for key design decisions. This section contains some extracts from this document.
7714
7715[heading Why duration needs operator%]
7716
7717This operator is convenient for computing where in a time frame a given duration lies. A motivating example is converting a duration into a "broken-down" time duration such as hours::minutes::seconds:
7718
7719    class ClockTime
7720    {
7721        typedef boost::chrono::hours hours;
7722        typedef boost::chrono::minutes minutes;
7723        typedef boost::chrono::seconds seconds;
7724    public:
7725        hours hours_;
7726        minutes minutes_;
7727        seconds seconds_;
7728
7729        template <class Rep, class Period>
7730          explicit ClockTime(const boost::chrono::duration<Rep, Period>& d)
7731            : hours_  (boost::chrono::duration_cast<hours>  (d)),
7732              minutes_(boost::chrono::duration_cast<minutes>(d % hours(1))),
7733              seconds_(boost::chrono::duration_cast<seconds>(d % minutes(1)))
7734              {}
7735    };
7736
7737[endsect]
7738
7739
7740[/======================================================]
7741[section:implementation Appendix: Implementation Notes]
7742
7743[heading Which APIs have been chosen to implement each clock on each platform?]
7744
7745The following table presents a resume of which API is used for each clock on each platform
7746[table Clock API correspondence
7747    [[Clock]                                [Windows Platform]          [Posix Platform]                 [Mac Platform]  ]
7748    [[__system_clock]                     [GetSystemTimeAsFileTime]   [clock_gettime( CLOCK_REALTIME)] [gettimeofday]          ]
7749    [[__steady_clock]                  [QueryPerformanceCounter and QueryPerformanceFrequency]
7750                                        [clock_gettime( CLOCK_STEADY)] [mach_timebase_info,mach_absolute_time]          ]
7751    [[__process_real_cpu_clock]           [GetProcessTimes]           [times]                         [times]  ]
7752    [[__process_system_cpu_clock]         [GetProcessTimes]           [times]                         [times]    ]
7753    [[__process_user_cpu_clock]           [GetProcessTimes]           [times]                         [times]  ]
7754    [[__process_cpu_clock]                [GetProcessTimes]           [times]                         [times]   ]
7755    [[__thread_clock]                     [GetThreadTimes]            [clock_gettime(pthread_getcpuclockid)]         [clock_gettime(pthread_getcpuclockid)]       ]
7756]
7757
7758[endsect]
7759
7760[/======================================================]
7761[section:faq Appendix: FAQ]
7762
7763[heading Why does process_cpu_clock sometimes give more cpu seconds than real seconds?]
7764
7765Ask your operating system supplier. The results have been inspected with a debugger, and both for Windows and Linux, that's what the OS appears to be reporting at times.
7766
7767
7768[heading Are integer overflows in the duration arithmetic detected and reported?]
7769
7770[*Boost.Ratio] avoids all kind of overflow that could result of arithmetic operation and that can be simplified. The typedefs durations don't detect overflow. You will need a duration representation that handles overflow.
7771
7772[heading Which clocks should be used to benchmarking?]
7773
7774Each clock has his own features. It depends on what do you need to benchmark. Most of the time, you could be interested in using a thread clock, but if you need to measure code subject to synchronization a process clock would be better. If you have a multi-process application, a system-wide clock could be needed.
7775
7776[heading Which clocks should be used for watching?]
7777
7778For trace purposes, it is probably best to use a system-wide clock.
7779
7780[endsect] [/section:faq Appendix: FAQ]
7781
7782[/====================================================]
7783[section:acknowledgements Appendix: Acknowledgements]
7784
7785The library's code was derived from Howard Hinnant's time2_demo prototype. Many thanks to Howard for making his code available under the Boost license. The original code was modified by Beman Dawes to conform to Boost conventions.
7786
7787time2_demo contained this comment:
7788
7789Much thanks to Andrei Alexandrescu, Walter Brown, Peter Dimov, Jeff Garland, Terry Golubiewski, Daniel Krugler, Anthony Williams.
7790
7791The file <boost/chrono_io.hpp> has been adapted from the experimental header `<chrono_io>` from Howard Hinnant. Thanks for all Howard.
7792
7793Howard Hinnant, who is the real author of the library, has provided valuable feedback and suggestions during the development of the library. In particular, The chrono_io_io.hpp source has been adapted from the experimental header `<chrono_io>` from Howard Hinnant.
7794
7795The acceptance review of Boost.Ratio took place between November 5th and 15th 2010. Many thanks to Anthony Williams, the review manager, and to all the reviewers: David Deakins, John Bytheway, Roland Bock and Paul A. Bristow.
7796
7797Thanks to Ronald Bock, Andrew Chinoff, Paul A. Bristow and John Bytheway for his help polishing the documentation.
7798
7799Thanks to Tom Tan for reporting some compiler issues with MSVC V10 beta and MinGW-gcc-4.4.0 and for the many pushing for an homogeneous `process_cpu_clock` clock.
7800
7801Thanks to Ronald Bock for reporting Valgind issues and for the many suggestions he made concerning the documentation.
7802
7803[endsect]
7804
7805[/=====================================]
7806[section:todo  Appendix: Future plans]
7807[/=====================================]
7808
7809[heading For later releases]
7810
7811* Add User defined literals for some durations.
7812* Include chrono::date as defined by Howard Hinnant [@http://home.roadrunner.com/~hinnant/bloomington/date.html here].
7813
7814[endsect]
7815
7816[endsect]
7817