Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74420 - in trunk/libs/chrono: doc example test
From: vicente.botet_at_[hidden]
Date: 2011-09-16 12:55:36


Author: viboes
Date: 2011-09-16 12:55:35 EDT (Fri, 16 Sep 2011)
New Revision: 74420
URL: http://svn.boost.org/trac/boost/changeset/74420

Log:
Chrono: Added some i/o facilities + a simple stopwatch
Added:
   trunk/libs/chrono/example/stopwatch_example.cpp (contents, props changed)
Text files modified:
   trunk/libs/chrono/doc/chrono.qbk | 764 +++++++++++++++++++++------------------
   trunk/libs/chrono/example/io_ex1.cpp | 3
   trunk/libs/chrono/test/Jamfile.v2 | 1
   3 files changed, 422 insertions(+), 346 deletions(-)

Modified: trunk/libs/chrono/doc/chrono.qbk
==============================================================================
--- trunk/libs/chrono/doc/chrono.qbk (original)
+++ trunk/libs/chrono/doc/chrono.qbk 2011-09-16 12:55:35 EDT (Fri, 16 Sep 2011)
@@ -145,7 +145,7 @@
 
 [def __nanoseconds [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `nanoseconds`]]
 [def __microseconds [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `microseconds`]]
-[def __milliseconds__ [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `milliseconds`]]
+[def __milliseconds [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `milliseconds`]]
 [def __seconds [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `seconds`]]
 [def __minutes [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `minutes`]]
 [def __hours [link chrono.reference.cpp0x.duration_hpp.duration_typedefs `hours`]]
@@ -165,6 +165,13 @@
 
 [def __duration_punct [link chrono.reference.io.chrono_io_hpp.duration_punct `duration_punct`]]
 
+[/==================]
+
+[def __round [link chrono.reference.round.html#chrono.reference.round. round_hpp `round`]]
+[def __ceil [link chrono.reference.round.html#chrono.reference.round.ceil_hpp `ceil`]]
+[def __floor [link chrono.reference.round.html#chrono.reference.round. floor_hpp `floor`]]
+
+
 
 [/===============]
 [section Overview]
@@ -276,8 +283,13 @@
 
 [heading I/O]
 
-It provides I/O for __duration and __time_point. It builds on `<boost/ratio/ratio_io.hpp>` to provide readable and flexible formatting and parsing for types in `<boost/chrono.hpp>`. The __duration unit names can be customized through a new facet: __duration_punct.
+It 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>.
+
+It builds on `<boost/ratio/ratio_io.hpp>` to provide readable and flexible formatting and parsing for types in `<boost/chrono.hpp>`.
+This textural representation uses [@http://en.wikipedia.org/wiki/SI_prefix#List_of_SI_prefixes SI prefixes] whenever possible. This makes it easy for `boost::milliseconds` to be represented by the text "milliseconds", or a hypothetical meter class to print out "millimeter".
+The __duration unit names can be customized through a new facet: __duration_punct.
 
+`system_clock::time_point` I/O is proposed in terms of UTC timepoints, strongly guided by ISO 9899:1999, Programming languages - C, ISO 9945:2003, Information Technology - Portable Operating System Interface (POSIX) and ISO 8601:2004, Data elements and interchange formats - Information interchange - Representation of dates and times.
 
 [heading Rounding utilities]
 
@@ -480,7 +492,7 @@
 * __hours
 * __minutes
 * __seconds
-* __milliseconds__
+* __milliseconds
 * __microseconds
 * __nanoseconds
 
@@ -550,7 +562,7 @@
 
     boost::chrono::__nanoseconds start;
     boost::chrono::__nanoseconds end;
- typedef boost::chrono::__milliseconds__ ms;
+ typedef boost::chrono::__milliseconds ms;
     ms d = boost::chrono::__duration_cast<ms>(end - start);
 
     // d now holds the number of milliseconds from start to end.
@@ -585,7 +597,7 @@
         return result;
     }
 
- typedef boost::chrono::__milliseconds__ ms;
+ typedef boost::chrono::__milliseconds ms;
     ms d = round_up<ms>(end - start);
     // d now holds the number of milliseconds from start to end, rounded up.
     std::cout << ms.count() << "ms\n";
@@ -602,21 +614,45 @@
     template <class To, class Rep, class Period>
     To
     floor(const duration<Rep, Period>& d)
+ {
+ return duration_cast<To>(d);
+ }
 
     // round to nearest, to even on tie
     template <class To, class Rep, class Period>
     To
- round(const duration<Rep, Period>& d);
-
+ round(const duration<Rep, Period>& d)
+ {
+ To t0 = duration_cast<To>(d);
+ To t1 = t0;
+ ++t1;
+ BOOST_AUTO(diff0, d - t0);
+ BOOST_AUTO(diff1, t1 - d);
+ if (diff0 == diff1)
+ {
+ if (t0.count() & 1)
+ return t1;
+ return t0;
+ }
+ else if (diff0 < diff1)
+ return t0;
+ return t1;
+ }
     // round up
     template <class To, class Rep, class Period>
     To
- ceil(const duration<Rep, Period>& d);
+ ceil(const duration<Rep, Period>& d)
+ {
+ To t = duration_cast<To>(d);
+ if (t < d)
+ ++t;
+ return t;
+ }
 
 
-The 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).
+The 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).
 
-Similarly, the comparison t < d in ceil is exact, even when there is no exact conversion between t and d.
+Similarly, the comparison `t < d` in __ceil is exact, even when there is no exact conversion between `t` and `d`.
 Example use of rounding functions
 
     #include <iostream>
@@ -952,7 +988,7 @@
     boost::chrono::__thread_clock::time_point start=boost::chrono::__thread_clock::now();
     // ... do something ...
 
- typedef boost::chrono::__milliseconds__ ms;
+ typedef boost::chrono::__milliseconds ms;
     ms d = boost::chrono::__thread_clock::now() - start;
     // d now holds the number of milliseconds from start to end.
     std::cout << ms.count() << "ms\n";
@@ -970,11 +1006,12 @@
 
 [section I/O]
 
+[section:duration_io duration]
+
 Any __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.
 
-__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). The short or long format can be easily chosen by streaming a `duration_short()` or `duration_long()` manipulator respectively.
+__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 manimulator `duration_fmt(duration_style::prefix)` or `duration_fmt(duration_style::symbol)`.
 
-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.
 
 __example
 
@@ -986,6 +1023,9 @@
         using namespace std;
         using namespace boost;
 
+ cout << "milliseconds(1) = "
+ << boost::chrono::milliseconds(1) << '\n';
+
         cout << "milliseconds(3) + microseconds(10) = "
              << boost::chrono::milliseconds(3) + boost::chrono::microseconds(10) << '\n';
 
@@ -996,6 +1036,32 @@
         cout << "ClockTick(3) + boost::chrono::nanoseconds(10) = "
              << ClockTick(3) + boost::chrono::nanoseconds(10) << '\n';
 
+ // ...
+ return 0;
+ }
+
+The output could be
+
+ milliseconds(1) = 1 microsecond
+ milliseconds(3) + microseconds(10) = 3010 microseconds
+ hours(3) + minutes(10) = 190 minutes
+ ClockTick(3) + nanoseconds(10) = 56 [1/5000000000]seconds
+
+ Set cout to use short names:
+ milliseconds(3) + microseconds(10) = 3010 [mu]s
+ hours(3) + minutes(10) = 190 m
+ ClockTick(3) + nanoseconds(10) = 56 [1/5000000000]s
+
+ system_clock::now() = 129387415616250000 [1/10000000]s since Jan 1, 1970
+ monotonic_clock::now() = 37297387636417 ns since boot
+
+ Set cout to use long names:
+ high_resolution_clock::now() = 37297387655134 nanoseconds since boot
+
+As 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.
+
+Sometimes 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 duration_short manipulator:
+
         cout << "\nSet cout to use short names:\n";
         cout << boost::chrono::duration_short;
 
@@ -1008,23 +1074,9 @@
         cout << "ClockTick(3) + nanoseconds(10) = "
              << ClockTick(3) + boost::chrono::nanoseconds(10) << '\n';
 
- cout << "\nsystem_clock::now() = " << boost::chrono::system_clock::now() << '\n';
- #ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
- cout << "steady_clock::now() = " << boost::chrono::steady_clock::now() << '\n';
- #endif
- cout << "\nSet cout to use long names:\n"
- << boost::chrono::duration_long
- << "high_resolution_clock::now() = "
- << boost::chrono::high_resolution_clock::now() << '\n';
- return 0;
- }
 
 The output could be
 
- milliseconds(3) + microseconds(10) = 3010 microseconds
- hours(3) + minutes(10) = 190 minutes
- ClockTick(3) + nanoseconds(10) = 56 [1/5000000000]seconds
-
     Set cout to use short names:
     milliseconds(3) + microseconds(10) = 3010 [mu]s
     hours(3) + minutes(10) = 190 m
@@ -1036,6 +1088,16 @@
     Set cout to use long names:
     high_resolution_clock::now() = 37297387655134 nanoseconds since boot
 
+The [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.
+
+When the format decision is taken at runtime, it could be better to use the parameterized manipulator __duration_fmt as in
+
+ duration_style::type style;
+ //...
+ cout << duration_fmt(style);
+
+
+
 Parsing a __duration follows rules analogous to the __duration converting constructor. A value and a unit (short or long) 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.
 
 For example a stream containing "5000 milliseconds" can be parsed into seconds, but if the stream contains "5001 milliseconds", parsing into `seconds` will cause `failbit` to be set.
@@ -1068,6 +1130,124 @@
 
 Note 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.
 
+Sometimes 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:
+
+ // round to nearest, to even on tie
+ template <class To, class Rep, class Period>
+ To
+ round(const duration<Rep, Period>& d)
+ {
+ To t0 = duration_cast<To>(d);
+ To t1 = t0;
+ ++t1;
+ auto diff0 = d - t0;
+ cout << "diff0 = " << diff0 << '\n';
+ auto diff1 = t1 - d;
+ cout << "diff1 = " << diff1 << '\n';
+ if (diff0 == diff1)
+ {
+ if (t0.count() & 1)
+ return t1;
+ return t0;
+ }
+ else if (diff0 < diff1)
+ return t0;
+ return t1;
+ }
+
+This 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:
+
+ milliseconds ms = round<milliseconds>(nanoseconds(123)); // diff0 = 123 nanoseconds
+ // diff1 = 999877 nanoseconds
+ milliseconds ms = round<milliseconds>(Ticks(44)); // diff0 = 2 [1/3000]seconds
+ // diff1 = 1 [1/3000]second
+
+This simple I/O will make duration so much more accessible to programmers.
+
+[endsect]
+
+[section:system_clock_time_point_io system_clock::time_point]
+
+__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].
+
+__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`.
+
+Furthermore, 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.
+
+ cout << system_clock::now() << '\n';
+
+could output
+
+ 2011-09-15 18:36:59.325132 +0000
+
+This 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.
+
+Of 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.
+
+Finally 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:
+
+ cout << time_fmt(local) << system_clock::now() << '\n';
+
+that could result in
+
+ 2011-09-15 14:36:59.325132 -0400
+
+Note 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()v. 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`:
+
+ tm* gmtime(const time_t* timer) -> UTC
+ tm* localtime(const time_t* timer) -> local time
+
+This proposal simply extends the C/POSIX `time_t` functionality to C++ syntax and `system_clock::time_point`.
+
+The `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:
+
+ cout << time_fmt(utc);
+
+And the formatting can be further customized by using the time format sequences. For example:
+
+ cout << time_fmt(local, "%A %B %e, %Y %r");
+ cout << system_clock::now() << '\n'; // Sunday April 24, 2011 02:36:59 PM
+
+When specifying formatting manipulators for wide streams, use wide strings.
+
+You can use the same manipulators with istreams to specify parsing sequences.
+
+Unfortunately 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()`.
+
+The 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).
+[endsect]
+
+[section:other_clocks_time_point_io Other clocks time_point]
+
+Unlike `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).
+
+In 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.
+
+ #ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
+ cout << "steady_clock::now() = " << boost::chrono::steady_clock::now() << '\n';
+ #endif
+ cout << "\nSet cout to use long names:\n"
+ << boost::chrono::duration_long
+ << "high_resolution_clock::now() = "
+ << boost::chrono::high_resolution_clock::now() << '\n';
+
+The output could be
+
+ steady_clock::now() = 37297387636417 ns since boot
+
+ Set cout to use long names:
+ high_resolution_clock::now() = 37297387655134 nanoseconds since boot
+
+
+[/
+There ...
+ cout << "\nsystem_clock::now() = " << boost::chrono::system_clock::now() << '\n';
+
+The output could be
+ system_clock::now() = 129387415616250000 [1/10000000]s since Jan 1, 1970
+
+]
+
 Parsing 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.
 
 __example
@@ -1127,6 +1307,8 @@
 [endsect]
 
 [endsect]
+
+[endsect]
 [/===============]
 [section Examples]
 [/===============]
@@ -1335,9 +1517,9 @@
 
 Usage
 
- xtime xt = to_xtime_truncate(seconds(3) + boost::chrono::__milliseconds__(251));
+ xtime xt = to_xtime_truncate(seconds(3) + boost::chrono::__milliseconds(251));
         print(xt);
- boost::chrono::milliseconds ms = boost::chrono::__duration_cast<boost::chrono::__milliseconds__>(from_xtime(xt));
+ boost::chrono::milliseconds ms = boost::chrono::__duration_cast<boost::chrono::__milliseconds>(from_xtime(xt));
         std::cout << ms.count() << " milliseconds\n";
         xt = to_xtime_round_up(ms);
         print(xt);
@@ -1921,10 +2103,10 @@
 
     this_thread::sleep_for(chrono::__seconds(3));
     this_thread::sleep_for(chrono::__nanoseconds(300));
- chrono::__system_clock::time_point time_limit = chrono::__system_clock::now() + chrono::__seconds_(4) + chrono::__milliseconds__(500);
+ chrono::__system_clock::time_point time_limit = chrono::__system_clock::now() + chrono::__seconds_(4) + chrono::__milliseconds(500);
     this_thread::sleep_until(time_limit);
 
- mut.try_lock_for(chrono::__milliseconds__(30));
+ mut.try_lock_for(chrono::__milliseconds(30));
     mut.try_lock_until(time_limit);
 
     cv.wait_for(m, chrono::__minutes(1)); // real code would put this in a loop
@@ -2193,7 +2375,7 @@
         // convenience typedefs
         typedef duration<boost::int_least64_t, nano> __nanoseconds; // at least 64 bits needed
         typedef duration<boost::int_least64_t, micro> __microseconds; // at least 55 bits needed
- typedef duration<boost::int_least64_t, milli> __milliseconds__; // at least 45 bits needed
+ typedef duration<boost::int_least64_t, milli> __milliseconds; // at least 45 bits needed
         typedef duration<boost::int_least64_t> __seconds; // at least 35 bits needed
         typedef duration<boost::int_least32_t, ratio< 60> > __minutes; // at least 29 bits needed
         typedef duration<boost::int_least32_t, ratio<3600> > __hours; // at least 23 bits needed
@@ -3242,12 +3424,34 @@
     namespace boost {
     namespace chrono {
 
- template <class CharT>
- class duration_punct;
+ // typedefs
+ struct duration_style
+ {
+ enum type {
+ prefix, symbol
+ };
+ };
+
+ struct timezone
+ {
+ enum type {
+ utc, local
+ };
+ };
 
         template <class Clock, class CharT>
         struct clock_string;
 
+ // facets
+
+ template <class CharT>
+ class duration_punct;
+
+ template <class CharT>
+ class timepoint_punct;
+
+ // manipulators
+
         template <class CharT, class Traits>
             std::basic_ostream<CharT, Traits>&
             duration_short(std::basic_ostream<CharT, Traits>& os);
@@ -3256,6 +3460,62 @@
             std::basic_ostream<CharT, Traits>&
             duration_long(std::basic_ostream<CharT, Traits>& os);
 
+
+ class duration_fmt;
+
+ template<class charT, class traits>
+ std::basic_ostream<charT, traits>&
+ operator <<(std::basic_ostream<charT, traits>& os, duration_fmt d);
+
+ template<class charT, class traits>
+ std::basic_istream<charT, traits>&
+ operator >>(std::basic_istream<charT, traits>& is, duration_fmt d);
+
+ unspecified time_fmt(timezone::type tz);
+ template<class charT>
+ unspecified time_fmt(timezone::type tz, basic_string<charT> f);
+ template<class charT>
+ unspecified time_fmt(timezone::type tz, const charT* f);
+
+ // i/o state savers
+
+ template<typename CharT = char, typename Traits = std::char_traits<CharT> >
+ struct duration_style_io_saver
+ {
+ typedef std::basic_ios<CharT, Traits> state_type;
+ typedef duration_style::type aspect_type;
+
+ explicit duration_style_io_saver(state_type &s);
+ duration_style_io_saver(state_type &s, aspect_type new_value);
+ ~duration_style_io_saver();
+ void restore();
+ };
+
+ template<typename CharT = char, typename Traits = std::char_traits<CharT> >
+ struct timezone_io_saver
+ {
+ typedef std::basic_ios<CharT, Traits> state_type;
+ typedef timezone::type aspect_type;
+
+ explicit timezone_io_saver(state_type &s);
+ timezone_io_saver(state_type &s, aspect_type new_value);
+ ~ timezone_io_saver();
+ void restore();
+ };
+
+ template<typename CharT = char, typename Traits = std::char_traits<CharT> >
+ struct time_fmt_io_saver
+ {
+ typedef std::basic_ios<CharT, Traits> state_type;
+
+ explicit time_fmt_io_saver(state_type &s);
+ time_fmt_io_saver(state_type &s, basic_string<charT> const& new_value);
+ ~ time_fmt_io_saver();
+ void restore();
+ };
+
+ // duration I/O
+
         template <class CharT, class Traits, class Rep, class Period>
             std::basic_ostream<CharT, Traits>&
             operator<<(std::basic_ostream<CharT, Traits>& os, const duration<Rep, Period>& d);
@@ -3264,6 +3524,20 @@
             std::basic_istream<CharT, Traits>&
             operator>>(std::basic_istream<CharT, Traits>& is, duration<Rep, Period>& d)
 
+ // system_clock I/O
+
+ template <class charT, class traits, class Duration>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const time_point<system_clock, Duration>& tp);
+
+ template <class charT, class traits, class Duration>
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ time_point<system_clock, Duration>& tp);
+
+ // Other Clocks I/O
+
         template <class CharT, class Traits, class Clock, class Duration>
             std::basic_ostream<CharT, Traits>&
             operator<<(std::basic_ostream<CharT, Traits>& os,
@@ -3277,37 +3551,27 @@
     }
     }
 
-[section:duration_punct Template Class `duration_punct<>`]
+[section:duration_style Scoped enum `duration_style`]
 
-The __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).
-
- template <class CharT>
- class duration_punct
- : public std::locale::facet
+ struct duration_style
         {
- public:
- typedef std::basic_string<CharT> string_type;
- enum {use_long, use_short};
-
- static std::locale::id id;
-
- explicit duration_punct(int use = use_long);
-
- duration_punct(int use,
- const string_type& long_seconds, const string_type& long_minutes,
- const string_type& long_hours, const string_type& short_seconds,
- const string_type& short_minutes, const string_type& short_hours);
+ enum type {
+ prefix, symbol
+ };
+ };
 
- duration_punct(int use, const duration_punct& d);
 
- template <class Period> string_type short_name() const;
- template <class Period> string_type long_name() const;
- template <class Period> string_type name() const;
+[endsect]
+[section:timezone Scoped enum `timezone`]
 
- bool is_short_name() const;
- bool is_long_name() const;
+ struct timezone
+ {
+ enum type {
+ utc, local
+ };
         };
 
+
 [endsect]
 
 [section:clock_string Template Class `clock_string<>`]
@@ -3434,6 +3698,86 @@
 
 [endsect]
 
+[section:duration_punct Template Class `duration_punct<>`]
+
+The __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).
+
+ template <class CharT>
+ class duration_punct
+ : public std::locale::facet
+ {
+ public:
+ typedef std::basic_string<CharT> string_type;
+ enum {use_long, use_short};
+
+ static std::locale::id id;
+
+ explicit duration_punct(int use = use_long);
+
+ duration_punct(int use,
+ const string_type& long_seconds, const string_type& long_minutes,
+ const string_type& long_hours, const string_type& short_seconds,
+ const string_type& short_minutes, const string_type& short_hours);
+
+ duration_punct(int use, const duration_punct& d);
+
+ template <class Period> string_type short_name() const;
+ template <class Period> string_type long_name() const;
+ template <class Period> string_type name() const;
+
+ bool is_short_name() const;
+ bool is_long_name() const;
+ };
+
+[endsect]
+
+[section: timepoint_punct Template Class `timepoint_punct <>`]
+
+ template <class charT>
+ class timepunct
+ : public std::locale::facet
+ {
+ public:
+ typedef std::basic_string<charT> string_type;
+
+ static std::locale::id id;
+
+ explicit timepoint_punct(size_t refs = 0);
+ timepoint_punct(timezone tz, string_type fmt, size_t refs = 0);
+
+ const string_type& fmt() const noexcept;
+ chrono::timezone timezone() const noexcept;
+ };
+
+[endsect]
+
+
+[section: duration_fmt Template Class `duration_fmt`]
+
+ class duration_fmt
+ {
+ public:
+
+ explicit duration_fmt(duration_style::type style) BOOST_CHRONO_NOEXCEPT;
+
+ #ifndef BOOST_NO_EXPLICIT_CONVERSION_OPERATORS
+ explicit
+ operator duration_style::type() const BOOST_CHRONO_NOEXCEPT;
+ #endif
+ duration_style::type get_duration_style() const BOOST_CHRONO_NOEXCEPT;
+ };
+
+ template<class charT, class traits>
+ std::basic_ostream<charT, traits>&
+ operator <<(std::basic_ostream<charT, traits>& os, duration_fmt d);
+
+ template<class charT, class traits>
+ std::basic_istream<charT, traits>&
+ operator >>(std::basic_istream<charT, traits>& is, duration_fmt d);
+
+[endsect]
+
+
 [section:manipulators I/O Manipulators]
 
 The short or long format can be easily chosen by streaming a `duration_short` or `duration_long` manipulator respectively.
@@ -3468,7 +3812,7 @@
             std::basic_ostream<CharT, Traits>&
             operator<<(std::basic_ostream<CharT, Traits>& os, const duration<Rep, Period>& d);
 
-__effects outputs the __duration as an abrevieated or long text format depending on the state of the __duration_punct facet.
+__effects outputs the __duration as an abbrevieated or long text format depending on the state of the __duration_punct facet.
 
 __returns the output stream
 
@@ -3485,7 +3829,7 @@
             operator<<(std::basic_ostream<CharT, Traits>& os,
                    const time_point<Clock, Duration>& tp);
 
-__effects outputs the __time_point as an abrevieated or long text format depending on the state of the __duration_punct facet.
+__effects outputs the __time_point as an abbrevieated or long text format depending on the state of the __duration_punct facet.
 
 __returns the output stream
 
@@ -4034,17 +4378,18 @@
 [/=================]
 
 [/==================================]
-[section:history Appendix A: History]
+[section:history Appendix: History]
 [/==================================]
 
-[section [*Version 1.3.0, September 3, 2011] ]
+[section [*Version 1.3.0, September 15, 2011] ]
 
 [*New Features:]
 * Added chrono utilities as defined By Howard Hinnant [@http://home.roadrunner.com/~hinnant/duration_io/chrono_util.html here].
+* Added chrono_io duration parameterized manipulator and i/o state saver.
 
 [*Fixes:]
 
-[endsect] [/section [*Version 1.3.0, September 3, 2011] ]
+[endsect] [/section [*Version 1.3.0] ]
 
 [section [*Version 1.2.0, September 3, 2011] ]
 
@@ -4053,7 +4398,7 @@
 * [@http://svn.boost.org/trac/boost/ticket/5669 #5669] Intel compiler failure to compile duration.hpp
 * [@http://svn.boost.org/trac/boost/ticket/2114 #2114] Enable visibility support (Boost.Chorno part)
 
-[endsect] [/section [*Version 1.2.0, September 3, 2011] ]
+[endsect] [/section [*Version 1.2.0] ]
 
 
 [section [*Version 1.1.0, Mars 17, 2011] ]
@@ -4061,14 +4406,14 @@
 [*New Features:]
 
 * [@http://svn.boost.org/trac/boost/ticket/???? #????] Added time_point unary operators +,-,++,-- and binary operators +=,-= with Rep al RHS.
-* [@http://svn.boost.org/trac/boost/ticket/5323 #5323] Add Associated type difference_type for chrono::time_point.
+* [@http://svn.boost.org/trac/boost/ticket/5323 #5323] Add Associated type difference_type for chrono::time_point.
 
 [*Fixes:]
 
 * [@http://svn.boost.org/trac/boost/ticket/5322 #5322] Explicit default constructed chrono::durations are uninitialized
  
 
-[endsect] [/section [*Version 1.1.0, Mars 17, 2011] ]
+[endsect] [/section [*Version 1.1.0] ]
 
 [section [*Version 1.0.0, January 6, 2011] ]
 
@@ -4104,7 +4449,7 @@
 
 * Removed some not useful parts as the test and the tickets.
 
-[endsect] [/section [*Version 1.0.0, January 6, 2011] ]
+[endsect] [/section [*Version 1.0.0] ]
 
 [/
 [section [*Version 0.6.0, September 22, 2010] ]
@@ -4390,7 +4735,7 @@
 [endsect]
 
 [/======================================]
-[section:rationale Appendix B: Rationale]
+[section:rationale Appendix: Rationale]
 
 See [@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.
 
@@ -4420,7 +4765,7 @@
 
 
 [/======================================================]
-[section:implementation Appendix C: Implementation Notes]
+[section:implementation Appendix: Implementation Notes]
 
 [heading Which APIs have been chosen to implement each clock on each platform?]
 
@@ -4440,7 +4785,7 @@
 [endsect]
 
 [/======================================================]
-[section:faq Appendix D: FAQ]
+[section:faq Appendix: FAQ]
 
 [heading Why does process_cpu_clock sometimes give more cpu seconds than real seconds?]
 
@@ -4459,10 +4804,10 @@
 
 For trace purposes, it is probably best to use a system-wide clock.
 
-[endsect] [/section:faq Appendix D: FAQ]
+[endsect] [/section:faq Appendix: FAQ]
 
 [/====================================================]
-[section:acknowledgements Appendix E: Acknowledgements]
+[section:acknowledgements Appendix: Acknowledgements]
 
 The 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.
 
@@ -4484,281 +4829,8 @@
 
 [endsect]
 
-[/
-[/====================================================]
-[section:tests Appendix F: Tests]
-
-In order to test you need to do.
-
- bjam libs/chrono/test
-
-You can also run a specific suite of test by doing
-
- cd libs/chrono/test
- bjam chrono
-
-
-[section chrono]
-[table
- [[Name] [kind] [Description] [Result] [Ticket]]
- [[chrono_unit_test] [run] [...] [Pass] [#]]
- [[explore_limits] [run] [...] [Pass] [#]]
- [[test_duration] [run] [...] [Pass] [#]]
- [[test_clock] [run] [...] [Pass] [#]]
- [[miscellaneous] [run] [...] [Pass] [#]]
- [[test_special_values] [run] [...] [Pass] [#]]
- [[manipulate_clock_object] [run] [...] [Pass] [#]]
- [[chrono_accuracy_test] [run] [...] [Pass] [#]]
-
-]
-[endsect]
-
-[section examples]
-[table
- [[Name] [kind] [Description] [Result] [Ticket]]
- [[cycle_count] [run] [...] [Pass] [#]]
- [[runtime_resolution] [run] [...] [Pass] [#]]
- [[xtime] [run] [...] [Pass] [#]]
- [[saturating] [run] [...] [Pass] [#]]
- [[min_time_point] [run] [...] [Pass] [#]]
- [[i_dont_like_the_default_duration_behavior] [run] [...] [Pass] [#]]
- [[simulated_thread_interface_demo] [run] [...] [Pass] [#]]
- [[timeval_demo] [run] [...] [Pass] [#]]
-]
-[endsect]
-
-
-[section Other Clocks]
-[table
- [[Name] [kind] [Description] [Result] [Ticket]]
- [[test_thread_clock] [run] [test basic uses of thread_clock.] [Pass] [#]]
-]
-[endsect]
-
-[section:typedefs Duration Typedef's]
-[table
- [[Name] [kind] [Description] [Result] [Ticket]]
- [[hours.pass] [run] [check how many hours we can count.] [Pass] [#]]
- [[minutes.pass] [run] [check how many minutes we can count.] [Pass] [#]]
- [[seconds.pass] [run] [check how many seconds we can count.] [Pass] [#]]
- [[milliseconds.pass] [run] [check how many milliseconds we can count.] [Pass] [#]]
- [[microseconds.pass] [run] [check how many microseconds we can count.] [Pass] [#]]
- [[nanoseconds.pass] [run] [check how many nanoseconds we can count.] [Pass] [#]]
-]
-[endsect]
-
-[section traits]
-[table
- [[Name] [kind] [Description] [Result] [Ticket]]
- [[specialization.duration.pass] [run] [check the correct common_type specialization has been done for duration.] [Pass] [#]]
- [[specialization.time_point.pass] [run] [check the correct common_type specialization has been done for time_point.] [Pass] [#]]
- [[is_fp.treat_as_floating_point.pass] [run] [check treat_as_floating_point<T> inherits from is_floating_point<T>.] [Pass] [#]]
- [[duration_values.max.pass] [run] [check max() corresponds to std::numeric_limits<T>::max().] [Pass] [#]]
- [[duration_values.min.pass] [run] [check min() corresponds to std::numeric_limits<T>::lowest().] [Pass] [#]]
- [[duration_values.zero.pass] [run] [check zero is 0.] [Pass] [#]]
-]
-[endsect]
-
-[section duration]
-[table
- [[Name] [kind] [Description] [Result] [Ticket]]
- [[duration.fail] [compile-fail] [If a program instantiates duration with a duration type for the template argument Rep a diagnostic is required.] [Pass] [#]]
- [[ratio.fail] [compile-fail] [Period shall be a specialization of ratio, diagnostic required..] [Pass] [#]]
- [[positive.fail] [compile-fail] [Period::num shall be positive, diagnostic required..] [Pass] [#]]
- [[defaul_ratio.pass] [run] [Test default template arg.] [Pass] [#]]
- [[types.pass] [run] [Test nested types.] [Pass] [#]]
-
- [[arithmetic.op_divide_ass.pass] [run] [check duration& operator/=(const rep& rhs);] [Pass] [#]]
- [[arithmetic.op_minusminusint.pass] [run] [check duration operator--(int);] [Pass] [#]]
- [[arithmetic.op_plus_ass.pass] [run] [check duration& operator+=(const duration& d);] [Pass] [#]]
- [[arithmetic.op_minus.pass] [run] [check duration operator-() const;] [Pass] [#]]
- [[arithmetic.op_mod_ass_duration.pass] [run] [check duration& operator%=(const duration& rhs);] [Pass] [#]]
- [[arithmetic.op_plusplus.pass] [run] [check duration& operator++();.] [Pass] [#]]
- [[arithmetic.op_minus_ass.pass] [run] [check duration& operator-=(const duration& d);] [Pass] [#]]
- [[arithmetic.op_mod_ass_rep.pass] [run] [check duration& operator%=(const rep& rhs)] [Pass] [#]]
- [[arithmetic.op_plusplusint.pass] [run] [check duration operator++(int);] [Pass] [#]]
- [[arithmetic.op_minusminus.pass] [run] [check duration operator--();] [Pass] [#]]
- [[arithmetic.op_plus.pass] [run] [check duration operator+() const;] [Pass] [#]]
- [[arithmetic.op_times_ass.pass] [run] [check duration& operator*=(const rep& rhs);.] [Pass] [#]]
-
- [[cast.duration_cast.pass] [run] [check template <class ToDuration, class Rep, class Period> ToDuration duration_cast(const duration<Rep, Period>& d);] [Pass] [#]]
- [[cast.toduration.fail] [compile-fail] [check ToDuration shall be an instantiation of duration.] [Pass] [#]]
-
- [[comparisons.op_equal.pass] [run] [check operator==() and operator!=().] [Pass] [#]]
- [[comparisons.op_less.pass] [run] [check operators <,<=,>,>=.] [Pass] [#]]
-
-]
-[table
- [[Name] [kind] [Description] [Result] [Ticket]]
-
- [[cons.convert_exact.pass] [run] [check exact conversions allowed for integral reps.] [Pass] [#]]
- [[cons.convert_float_to_int.fail] [compile-fail] [check conversions from floating-point to integral durations disallowed.] [Pass] [#]]
- [[cons.convert_inexact.fail] [compile-fail] [check inexact conversions disallowed for integral reps.] [Pass] [#]]
- [[cons.convert_inexact.pass] [run] [check inexact conversions allowed for floating-point reps.] [Pass] [#]]
- [[cons.convert_int_to_float.pass] [run] [check conversions from integral to floating-point durations allowed.] [Pass] [#]]
- [[cons.default.pass] [run] [check Rep must be default initialized, not initialized with 0.] [Pass] [#]]
- [[cons.rep.pass] [run] [check explicit duration(const Rep2& r).] [Pass] [#]]
- [[cons.rep01.fail] [compile-fail] [test for explicit.] [Pass] [#]]
- [[cons.rep02.fail] [compile-fail] [check Rep2 shall be implicitly convertible to rep.] [Pass] [#]]
- [[cons.rep02.pass] [run] [check construct double with int.] [Pass] [#]]
- [[cons.rep03.fail] [compile-fail] [treat_as_floating_point<Rep2>::value shall be false.] [Pass] [#]]
-
- [[nonmember.op_plus.pass] [run] [check operator+(d,d).] [Pass] [#]]
- [[nonmember.op_minus.pass] [run] [check operator-(d,d).] [Pass] [#]]
- [[nonmember.op_divide_duration.pass] [run] [check operator/(d,d).] [Pass] [#]]
- [[nonmember.op_divide_rep.fail] [compile-fail] [check operator/(d,r) fails with different rep.] [Pass] [#]]
- [[nonmember.op_divide_rep.pass] [run] [check operator/(d,r).] [Pass] [#]]
- [[nonmember.op_mod_duration.pass] [run] [check operator%(d,d).] [Pass] [#]]
- [[nonmember.op_mod_rep.pass] [run] [check operator%(d,r).] [Pass] [#]]
- [[nonmember.op_times_rep.pass] [run] [check operator*(d,r).] [Pass] [#]]
- [[nonmember.op_times_rep1.fail] [compile-fail] [check operator*(d,r) fails with different rep.] [Pass] [#]]
- [[nonmember.op_times_rep2.fail] [compile-fail] [check operator*(r,d) fails with different rep.] [Pass] [#]]
- [[special.max.pass] [run] [check coherency between max and duration_values traits.] [Pass] [#]]
- [[special.min.pass] [run] [check coherency between min and duration_values traits.] [Pass] [#]]
- [[special.zero.pass] [run] [check coherency between zero and duration_values traits.] [Pass] [#]]
-]
-[endsect]
-
-[section time_point]
-[table
- [[Name] [kind] [Description] [Result] [Ticket]]
- [[default_duration.pass] [run] [check .] [Pass] [#]]
- [[duration.fail] [compile-fail] [check .] [Pass] [#]]
-
- [[arithmetic.op_plus_ass.pass] [run] [check .] [Pass] [#]]
- [[arithmetic.op_plus_ass.pass] [run] [check .] [Pass] [#]]
- [[cast.time_point_cast.pass] [run] [check .] [Pass] [#]]
- [[cast.toduration.fail] [compile-fail] [check .] [Pass] [#]]
- [[comparisons.op_equal.fail] [compile-fail] [check .] [Pass] [#]]
- [[comparisons.op_equal.pass] [run] [check .] [Pass] [#]]
- [[comparisons.op_less.fail] [compile-fail] [check .] [Pass] [#]]
- [[comparisons.op_less.pass] [run] [check .] [Pass] [#]]
- [[cons.convert.fail] [compile-fail] [check .] [Pass] [#]]
- [[cons.convert.pass] [run] [check .] [Pass] [#]]
- [[cons.default.pass] [run] [check .] [Pass] [#]]
- [[cons.duration..fail] [compile-fail] [check .] [Pass] [#]]
- [[cons.duration.pass] [run] [check .] [Pass] [#]]
- [[nonmember.op_plus.pass] [run] [check .] [Pass] [#]]
- [[nonmember.op_minus_time_point.pass] [run] [check .] [Pass] [#]]
- [[nonmember.op_minus_duration.pass] [run] [check .] [Pass] [#]]
- [[special.max.pass] [run] [check .] [Pass] [#]]
- [[special.min.pass] [run] [check .] [Pass] [#]]
-]
-[endsect]
-
-[section clock]
-[table
- [[Name] [kind] [Description] [Result] [Ticket]]
- [[hires.consistency.pass] [run] [check .] [Pass] [#]]
- [[hires.now.pass] [run] [check .] [Pass] [#]]
- [[steady.consistency.pass] [run] [check .] [Pass] [#]]
- [[steady.now.pass] [run] [check .] [Pass] [#]]
- [[system.consistency.pass] [run] [check .] [Pass] [#]]
- [[system.now.pass] [run] [check .] [Pass] [#]]
- [[system.from_time_t.pass] [run] [check .] [Pass] [#]]
- [[system.rep_signed.pass] [run] [check .] [Pass] [#]]
- [[system.rep_signed.pass] [run] [check .] [Pass] [#]]
- [[process.consistency.pass] [run] [check .] [Pass] [#]]
- [[process.now.pass] [run] [check .] [Pass] [#]]
- [[thread.consistency.pass] [run] [check .] [Pass] [#]]
- [[thread.now.pass] [run] [check .] [Pass] [#]]
-]
-
-
-[endsect]
-
-
-[section io examples]
-[table
- [[Name] [kind] [Description] [Result] [Ticket]]
- [[io_ex1.pass] [run] [check .] [Pass] [#]]
- [[io_ex2.pass] [run] [check .] [Pass] [#]]
- [[io_ex3.pass] [run] [check .] [Pass] [#]]
- [[io_ex4.pass] [run] [check .] [Pass] [#]]
- [[io_ex5.pass] [run] [check .] [Pass] [#]]
-]
-[endsect]
-
-
-
-[endsect]
-[/=====================================]
-[section:tickets Appendix G: Tickets]
-
-[table
- [[Ticket] [Description] [Resolution] [State]]
- [[0] [ Issues raised by Michael Marcin: In the past I've seen QueryPerformanceCounter give incorrect results,
- especially with SpeedStep processors on laptops. This was many years ago and
- might have been fixed by service packs and drivers.
-
- Typically you check the results of QPC against GetTickCount to see if the
- results are reasonable.
- http://support.microsoft.com/kb/274323
-
- I've also heard of problems with QueryPerformanceCounter in multi-processor
- systems.
-
- I know some people SetThreadAffinityMask to 1 for the current thread call
- their QueryPerformance* functions then restore SetThreadAffinityMask. This
- seems horrible to me because it forces your program to jump to another
- physical processor if it isn't already on cpu0 but they claim it worked well
- in practice because they called the timing functions infrequently.
-
- In the past I have chosen to use timeGetTime with timeBeginPeriod(1) for
- high resolution timers to avoid these issues.
- ] [???] [*Open*]]
- [[1] [operator/ was ambiguous] [Disambiguate duration operator/] [Closed]]
- [[2] [CLOCK_STEADY is not defined with cygwin/gcc 3.4] [Disable code when BOOST_CHRONO_HAS_CLOCK_STEADY is not defined.] [Closed]]
- [[3] [result of metafunctions ratio_multiply and ratio_divide were not normalized ratios] [Use of the nested ratio typedef type on ratio arithmetic operations.] [Closed]]
- [[4] [Copy constructor from similar duration masked the defaulted operations] [Added duration defaulted implementations] [Closed]]
- [[5] [INTMAX_C is not always defined] [Replace INTMAX_C by BOOST_INTMAX_C until boost/cstdint.hpp ensures INTMAX_C is always defined.] [Closed]]
- [[6] [undefined BOOST_CHRONO_HAS_CLOCK_STEADY when BOOST_CHRONO_WINDOWS_API] [Define BOOST_CHRONO_HAS_CLOCK_STEADY when BOOST_CHRONO_WINDOWS_API] [Closed]]
- [[7] [min/max macros intrussion] [Take care of Boost min/max recommendations] [Closed]]
- [[8] [declaration of 'typedef class boost::chrono::duration<..> changes meaning of 'duration'] [complete qualification when defining nested typedef duration on clocks to avoid the following compile error:] [Closed]]
- [[9] [VC++ warnings] [disable VC++ foolishness] [Closed]]
-]
-[table
- [[Ticket] [Description] [Resolution] [State]]
-
- [[10] [conversion warning in test_duration] [removal of conversion warning in test_duration] [Closed]]
- [[11] [MSVC reports a warning instead of an error when there is an integral constant overflow] [manage with MSVC reporting a warning instead of an error when there is an integral constant overflow] [Closed]]
- [[12] [ambiguities with MSVC when using detail:: namespace] [Qualify with boost::detail boost::chrono::detail ] [Closed]]
- [[13] [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'] [don't include inlines functions using the std::string m_format] [Closed]]
- [[14] [Bad use of duration(0) on template classes] [remplace by duration::zero()] [Closed]]
- [[15] [suspend doesn't works: partial_ not initialized] [initialize with duration::zero()] [Closed]]
- [[16] [suspend doesn't works: elapsed doesn't take care of partial_] [take care of partial] [Closed]]
- [[17] [suspend doesn't works: bad use of system::error_code & ec] [replace by system::error_code ec] [Closed]]
- [[18] [warnings on mingw-gcc.4.4:
-
-..\..\../boost/chrono/chrono.hpp: In copy constructor 'boost::chrono::time_point<boost::chrono::process_cpu_clock,
-boost::chrono::duration<boost::chrono::process_cpu_clock::times, boost::ratio<1ll, 1000000000ll> >
->::time_point(const boost::chrono::time_point<boost::chrono::process_cpu_clock,
-boost::chrono::duration<boost::chrono::process_cpu_clock::times, boost::ratio<1ll, 1000000000ll> > >&)':
-..\..\../boost/chrono/chrono.hpp:816: warning: suggest parentheses around '&&' within '||'
-..\..\../boost/chrono/chrono.hpp:816: warning: suggest parentheses around '&&' within '||'
-
-] [???] [Closed]]
- [[19] [Use of Specific formatters doesn't works] [] [Closed]]
-
- [[20] [boost/chrono/scoped_suspend.hpp(31) : warning C4520: 'boost::chrono::scoped_suspend<Clock>' : multiple default constructors specified
-] [Remove the default constructor deletion ] [Closed]]
- [[21] [suspendible_clock_test doesn't works in my mingw environement] [(issue with tss)] [*Open*]]
- [[22] [error_code not initialized] [Use ec.clear() before throwing a exception.] [Closed]]
- [[23] [boost/thread/detail/cv_status.hpp file was not commited] [commit file] [Closed]]
- [[24] [Boost.Conversion was not packaged] [Package it] [Closed]]
- [[25] [Valgrind issue: Conditional jump or move depends on uninitialised value(s)] [Replace the test] [Closed]]
- [/[#] [XXXX] [XXXX] [Closed]]
-]
-
-
-
-
-
-[endsect]
-
-]
 [/=====================================]
-[section:todo Appendix F: Future plans]
+[section:todo Appendix: Future plans]
 [/=====================================]
 
 [heading For later releases]

Modified: trunk/libs/chrono/example/io_ex1.cpp
==============================================================================
--- trunk/libs/chrono/example/io_ex1.cpp (original)
+++ trunk/libs/chrono/example/io_ex1.cpp 2011-09-16 12:55:35 EDT (Fri, 16 Sep 2011)
@@ -22,6 +22,8 @@
     using namespace boost;
     using namespace boost::chrono;
 
+ cout << "milliseconds(1) = "
+ << milliseconds(1) << '\n';
     cout << "milliseconds(3) + microseconds(10) = "
          << milliseconds(3) + microseconds(10) << '\n';
 
@@ -45,6 +47,7 @@
          << ClockTick(3) + nanoseconds(10) << '\n';
 
     cout << "\nsystem_clock::now() = " << system_clock::now() << '\n';
+ cout << "\nsystem_clock::now() = " << time_fmt(chrono::timezone::local) << system_clock::now() << '\n';
 #ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
     cout << "steady_clock::now() = " << steady_clock::now() << '\n';
 #endif

Added: trunk/libs/chrono/example/stopwatch_example.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/chrono/example/stopwatch_example.cpp 2011-09-16 12:55:35 EDT (Fri, 16 Sep 2011)
@@ -0,0 +1,34 @@
+// example/stopwatch_example.cpp ---------------------------------------------------//
+// Copyright Beman Dawes 2006, 2008
+// Copyright 2009-2011 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+// See http://www.boost.org/libs/chrono/stopwatches for documentation.
+
+//#include <iostream>
+#include <boost/chrono/stopwatches/simple_stopwatch.hpp>
+#include <boost/chrono/chrono_io.hpp>
+#include <cmath>
+
+using namespace boost::chrono;
+
+int f1(long j)
+{
+ simple_stopwatch<> sw;
+
+ for ( long i = 0; i < j; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ std::cout << "f1("<< j <<") Elapsed time: " << sw.elapsed() << std::endl;
+ return 0;
+}
+int main()
+{
+ simple_stopwatch<> sw;
+
+ f1(1000);
+ f1(2000);
+ f1(3000);
+ std::cout << "main() Elapsed time: " << sw.elapsed() << std::endl;
+ return 0;
+}

Modified: trunk/libs/chrono/test/Jamfile.v2
==============================================================================
--- trunk/libs/chrono/test/Jamfile.v2 (original)
+++ trunk/libs/chrono/test/Jamfile.v2 2011-09-16 12:55:35 EDT (Fri, 16 Sep 2011)
@@ -183,6 +183,7 @@
         [ chrono-run ../example/french.cpp ]
         [ chrono-run ../example/rounding.cpp ]
         #[ chrono-run ../example/await_keystroke.cpp ]
+ [ chrono-run ../example/stopwatch_example.cpp ]
         ;
 
     test-suite "traits"


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk