|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81056 - in branches/release: boost/chrono boost/chrono/detail boost/chrono/io boost/chrono/io_v1 libs/chrono/doc libs/chrono/src libs/chrono/test/duration libs/chrono/test/io libs/chrono/test/time_point libs/chrono/test/traits
From: vicente.botet_at_[hidden]
Date: 2012-10-24 20:07:53
Author: viboes
Date: 2012-10-24 20:07:52 EDT (Wed, 24 Oct 2012)
New Revision: 81056
URL: http://svn.boost.org/trac/boost/changeset/81056
Log:
Chrono: merge 81040-81041,81044-81045
Properties modified:
branches/release/boost/chrono/detail/ (props changed)
branches/release/boost/chrono/io/ (props changed)
branches/release/boost/chrono/io_v1/ (props changed)
branches/release/libs/chrono/src/ (props changed)
branches/release/libs/chrono/test/duration/ (props changed)
branches/release/libs/chrono/test/io/ (props changed)
branches/release/libs/chrono/test/time_point/ (props changed)
branches/release/libs/chrono/test/traits/ (props changed)
Text files modified:
branches/release/boost/chrono/config.hpp | 7
branches/release/boost/chrono/io/time_point_io.hpp | 369 +++++++++++++++++++++++++++++++++++++++
branches/release/libs/chrono/doc/chrono.qbk | 109 ++++++++++
branches/release/libs/chrono/test/io/time_point_input.cpp | 58 +++++
branches/release/libs/chrono/test/io/time_point_output.cpp | 91 +++++++++
5 files changed, 607 insertions(+), 27 deletions(-)
Modified: branches/release/boost/chrono/config.hpp
==============================================================================
--- branches/release/boost/chrono/config.hpp (original)
+++ branches/release/boost/chrono/config.hpp 2012-10-24 20:07:52 EDT (Wed, 24 Oct 2012)
@@ -25,6 +25,13 @@
#define BOOST_USE_WINDOWS_H
#endif
+#if ! defined BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT \
+ && ! defined BOOST_CHRONO_DONT_PROVIDE_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT
+
+# define BOOST_CHRONO_DONT_PROVIDE_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT
+
+#endif
+
// BOOST_CHRONO_POSIX_API, BOOST_CHRONO_MAC_API, or BOOST_CHRONO_WINDOWS_API
// can be defined by the user to specify which API should be used
Modified: branches/release/boost/chrono/io/time_point_io.hpp
==============================================================================
--- branches/release/boost/chrono/io/time_point_io.hpp (original)
+++ branches/release/boost/chrono/io/time_point_io.hpp 2012-10-24 20:07:52 EDT (Wed, 24 Oct 2012)
@@ -3,9 +3,18 @@
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
+
+//===-------------------------- locale ------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
//
+//===----------------------------------------------------------------------===//
+
// This code was adapted by Vicente from Howard Hinnant's experimental work
-// on chrono i/o to Boost
+// on chrono i/o to Boost and some functions from libc++/locale to emulate the missing time_get::get()
#ifndef BOOST_CHRONO_IO_TIME_POINT_IO_HPP
#define BOOST_CHRONO_IO_TIME_POINT_IO_HPP
@@ -23,6 +32,11 @@
#include <locale>
#include <string.h>
+#define BOOST_CHRONO_INTERNAL_TIMEGM defined BOOST_WINDOWS && ! defined(__CYGWIN__)
+//#define BOOST_CHRONO_INTERNAL_TIMEGM 1
+
+#define BOOST_CHRONO_USES_INTERNAL_TIME_GET
+
namespace boost
{
namespace chrono
@@ -30,6 +44,309 @@
namespace detail
{
+ template <class CharT, class InputIterator = std::istreambuf_iterator<CharT> >
+ struct time_get
+ {
+ std::time_get<CharT> const &that_;
+ time_get(std::time_get<CharT> const& that) : that_(that) {}
+
+ typedef std::time_get<CharT> facet;
+ typedef typename facet::iter_type iter_type;
+ typedef typename facet::char_type char_type;
+ typedef std::basic_string<char_type> string_type;
+
+ static int
+ get_up_to_n_digits(
+ InputIterator& b, InputIterator e,
+ std::ios_base::iostate& err,
+ const std::ctype<CharT>& ct,
+ int n)
+ {
+ // Precondition: n >= 1
+ if (b == e)
+ {
+ err |= std::ios_base::eofbit | std::ios_base::failbit;
+ return 0;
+ }
+ // get first digit
+ CharT c = *b;
+ if (!ct.is(std::ctype_base::digit, c))
+ {
+ err |= std::ios_base::failbit;
+ return 0;
+ }
+ int r = ct.narrow(c, 0) - '0';
+ for (++b, --n; b != e && n > 0; ++b, --n)
+ {
+ // get next digit
+ c = *b;
+ if (!ct.is(std::ctype_base::digit, c))
+ return r;
+ r = r * 10 + ct.narrow(c, 0) - '0';
+ }
+ if (b == e)
+ err |= std::ios_base::eofbit;
+ return r;
+ }
+
+
+ void get_day(
+ int& d,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ int t = get_up_to_n_digits(b, e, err, ct, 2);
+ if (!(err & std::ios_base::failbit) && 1 <= t && t <= 31)
+ d = t;
+ else
+ err |= std::ios_base::failbit;
+ }
+
+ void get_month(
+ int& m,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ int t = get_up_to_n_digits(b, e, err, ct, 2) - 1;
+ if (!(err & std::ios_base::failbit) && t <= 11)
+ m = t;
+ else
+ err |= std::ios_base::failbit;
+ }
+
+
+ void get_year4(int& y,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ int t = get_up_to_n_digits(b, e, err, ct, 4);
+ if (!(err & std::ios_base::failbit))
+ y = t - 1900;
+ }
+
+ void
+ get_hour(int& h,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ int t = get_up_to_n_digits(b, e, err, ct, 2);
+ if (!(err & std::ios_base::failbit) && t <= 23)
+ h = t;
+ else
+ err |= std::ios_base::failbit;
+ }
+
+ void
+ get_minute(int& m,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ int t = get_up_to_n_digits(b, e, err, ct, 2);
+ if (!(err & std::ios_base::failbit) && t <= 59)
+ m = t;
+ else
+ err |= std::ios_base::failbit;
+ }
+
+ void
+ get_second(int& s,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ int t = get_up_to_n_digits(b, e, err, ct, 2);
+ if (!(err & std::ios_base::failbit) && t <= 60)
+ s = t;
+ else
+ err |= std::ios_base::failbit;
+ }
+
+
+
+ InputIterator get(
+ iter_type b, iter_type e,
+ std::ios_base& iob,
+ std::ios_base::iostate& err,
+ std::tm* tm,
+ char fmt, char) const
+ {
+ err = std::ios_base::goodbit;
+ const std::ctype<char_type>& ct = std::use_facet<std::ctype<char_type> >(iob.getloc());
+
+ switch (fmt)
+ {
+// case 'a':
+// case 'A':
+// that_.get_weekdayname(tm->tm_wday, b, e, err, ct);
+// break;
+// case 'b':
+// case 'B':
+// case 'h':
+// that_.get_monthname(tm->tm_mon, b, e, err, ct);
+// break;
+// case 'c':
+// {
+// const string_type& fm = this->c();
+// b = that_.get(b, e, iob, err, tm, fm.data(), fm.data() + fm.size());
+// }
+// break;
+ case 'd':
+ case 'e':
+ get_day(tm->tm_mday, b, e, err, ct);
+ //std::cerr << "tm_mday= "<< tm->tm_mday << std::endl;
+
+ break;
+// case 'D':
+// {
+// const char_type fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'};
+// b = that_.get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
+// }
+// break;
+// case 'F':
+// {
+// const char_type fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'};
+// b = that_.get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
+// }
+// break;
+ case 'H':
+ get_hour(tm->tm_hour, b, e, err, ct);
+ //std::cerr << "tm_hour= "<< tm->tm_hour << std::endl;
+ break;
+// case 'I':
+// that_.get_12_hour(tm->tm_hour, b, e, err, ct);
+// break;
+// case 'j':
+// that_.get_day_year_num(tm->tm_yday, b, e, err, ct);
+// break;
+ case 'm':
+ get_month(tm->tm_mon, b, e, err, ct);
+ //std::cerr << "tm_mon= "<< tm->tm_mon << std::endl;
+ break;
+ case 'M':
+ get_minute(tm->tm_min, b, e, err, ct);
+ //std::cerr << "tm_min= "<< tm->tm_min << std::endl;
+ break;
+// case 'n':
+// case 't':
+// that_.get_white_space(b, e, err, ct);
+// break;
+// case 'p':
+// that_.get_am_pm(tm->tm_hour, b, e, err, ct);
+// break;
+// case 'r':
+// {
+// const char_type fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'};
+// b = that_.get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
+// }
+// break;
+// case 'R':
+// {
+// const char_type fm[] = {'%', 'H', ':', '%', 'M'};
+// b = that_.get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
+// }
+// break;
+// case 'S':
+// that_.get_second(tm->tm_sec, b, e, err, ct);
+// break;
+// case 'T':
+// {
+// const char_type fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
+// b = that_.get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
+// }
+// break;
+// case 'w':
+// that_.get_weekday(tm->tm_wday, b, e, err, ct);
+// break;
+// case 'x':
+// return that_.get_date(b, e, iob, err, tm);
+// case 'X':
+// {
+// const string_type& fm = this->X();
+// b = that_.get(b, e, iob, err, tm, fm.data(), fm.data() + fm.size());
+// }
+// break;
+// case 'y':
+// that_.get_year(tm->tm_year, b, e, err, ct);
+ break;
+ case 'Y':
+ get_year4(tm->tm_year, b, e, err, ct);
+ //std::cerr << "tm_year= "<< tm->tm_year << std::endl;
+ break;
+// case '%':
+// that_.get_percent(b, e, err, ct);
+// break;
+ default:
+ err |= std::ios_base::failbit;
+ }
+ return b;
+ }
+
+
+ InputIterator get(
+ iter_type b, iter_type e,
+ std::ios_base& iob,
+ std::ios_base::iostate& err, std::tm* tm,
+ const char_type* fmtb, const char_type* fmte) const
+ {
+ const std::ctype<char_type>& ct = std::use_facet<std::ctype<char_type> >(iob.getloc());
+ err = std::ios_base::goodbit;
+ while (fmtb != fmte && err == std::ios_base::goodbit)
+ {
+ if (b == e)
+ {
+ err = std::ios_base::failbit;
+ break;
+ }
+ if (ct.narrow(*fmtb, 0) == '%')
+ {
+ if (++fmtb == fmte)
+ {
+ err = std::ios_base::failbit;
+ break;
+ }
+ char cmd = ct.narrow(*fmtb, 0);
+ char opt = '\0';
+ if (cmd == 'E' || cmd == '0')
+ {
+ if (++fmtb == fmte)
+ {
+ err = std::ios_base::failbit;
+ break;
+ }
+ opt = cmd;
+ cmd = ct.narrow(*fmtb, 0);
+ }
+ b = get(b, e, iob, err, tm, cmd, opt);
+ ++fmtb;
+ }
+ else if (ct.is(std::ctype_base::space, *fmtb))
+ {
+ for (++fmtb; fmtb != fmte && ct.is(std::ctype_base::space, *fmtb); ++fmtb)
+ ;
+ for ( ; b != e && ct.is(std::ctype_base::space, *b); ++b)
+ ;
+ }
+ else if (ct.toupper(*b) == ct.toupper(*fmtb))
+ {
+ ++b;
+ ++fmtb;
+ }
+ else
+ err = std::ios_base::failbit;
+ }
+ if (b == e)
+ err |= std::ios_base::eofbit;
+ return b;
+ }
+
+ };
+
+
template <class CharT>
class time_manip: public manip<time_manip<CharT> >
{
@@ -338,7 +655,7 @@
namespace detail
{
-#if defined BOOST_WINDOWS && ! defined(__CYGWIN__)
+#if BOOST_CHRONO_INTERNAL_TIMEGM
int is_leap(int year)
{
if(year % 400 == 0)
@@ -397,6 +714,7 @@
#endif
} // detail
+#if defined BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT
template <class CharT, class Traits, class Duration>
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os, const time_point<system_clock, Duration>& tp)
@@ -420,7 +738,7 @@
timezone tz = get_timezone(os);
std::locale loc = os.getloc();
- time_t t = system_clock::to_time_t(tp);
+ time_t t = system_clock::to_time_t(time_point_cast<system_clock::duration>(tp));
std::tm tm;
if (tz == timezone::local)
{
@@ -530,6 +848,7 @@
//std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
return os;
}
+#endif
namespace detail
{
@@ -578,17 +897,22 @@
}
min = min * 10 + cn - '0';
}
- if (++b == e) err |= std::ios_base::eofbit;
+ if (++b == e) {
+ err |= std::ios_base::eofbit;
+ }
min += hr * 60;
min *= sn;
}
else
+ {
err |= std::ios_base::eofbit | std::ios_base::failbit;
+ }
return minutes(min);
}
} // detail
+#if defined BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT
template <class CharT, class Traits, class Duration>
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, time_point<system_clock, Duration>& tp)
@@ -619,7 +943,12 @@
{ '%', 'Y', '-', '%', 'm', '-', '%', 'd', ' ', '%', 'H', ':', '%', 'M', ':' };
pb = pattern;
pe = pb + sizeof (pattern) / sizeof(CharT);
+#if defined BOOST_CHRONO_USES_INTERNAL_TIME_GET
+ const detail::time_get<CharT>& dtg(tg);
+ dtg.get(is, 0, is, err, &tm, pb, pe);
+#else
tg.get(is, 0, is, err, &tm, pb, pe);
+#endif
if (err & std::ios_base::failbit) goto exit;
double sec;
CharT c = CharT();
@@ -629,6 +958,7 @@
err |= std::ios_base::failbit;
goto exit;
}
+ //std::cerr << "sec= "<< sec << std::endl;
It i(is);
It eof;
c = *i;
@@ -638,21 +968,30 @@
goto exit;
}
minutes min = detail::extract_z(i, eof, err, ct);
+ //std::cerr << "min= "<< min.count() << std::endl;
+
if (err & std::ios_base::failbit) goto exit;
time_t t;
-#if defined BOOST_WINDOWS && ! defined(__CYGWIN__)
+#if BOOST_CHRONO_INTERNAL_TIMEGM
t = detail::internal_timegm(&tm);
#else
t = timegm(&tm);
#endif
- tp = system_clock::from_time_t(t) - min + round<microseconds> (duration<double> (sec));
+ tp = time_point_cast<Duration>(
+ system_clock::from_time_t(t) - min + round<microseconds> (duration<double> (sec))
+ );
}
else
{
const CharT z[2] =
{ '%', 'z' };
const CharT* fz = std::search(pb, pe, z, z + 2);
+#if defined BOOST_CHRONO_USES_INTERNAL_TIME_GET
+ const detail::time_get<CharT>& dtg(tg);
+ dtg.get(is, 0, is, err, &tm, pb, fz);
+#else
tg.get(is, 0, is, err, &tm, pb, fz);
+#endif
minutes minu(0);
if (fz != pe)
{
@@ -663,7 +1002,7 @@
}
It i(is);
It eof;
- minu = extract_z(i, eof, err, ct);
+ minu = detail::extract_z(i, eof, err, ct);
if (err & std::ios_base::failbit) goto exit;
if (fz + 2 != pe)
{
@@ -672,21 +1011,32 @@
err |= std::ios_base::failbit;
goto exit;
}
+#if defined BOOST_CHRONO_USES_INTERNAL_TIME_GET
+ const detail::time_get<CharT>& dtg(tg);
+ dtg.get(is, 0, is, err, &tm, fz + 2, pe);
+#else
tg.get(is, 0, is, err, &tm, fz + 2, pe);
+#endif
if (err & std::ios_base::failbit) goto exit;
}
}
tm.tm_isdst = -1;
time_t t;
if (tz == timezone::utc || fz != pe)
-#if defined BOOST_WINDOWS && ! defined(__CYGWIN__)
+ {
+#if BOOST_CHRONO_INTERNAL_TIMEGM
t = detail::internal_timegm(&tm);
#else
t = timegm(&tm);
#endif
+ }
else
+ {
t = mktime(&tm);
- tp = system_clock::from_time_t(t) - minu;
+ }
+ tp = time_point_cast<Duration>(
+ system_clock::from_time_t(t) - minu
+ );
}
}
#ifndef BOOST_NO_EXCEPTIONS
@@ -699,6 +1049,7 @@
}
return is;
}
+#endif
#endif //UTC
} // chrono
Modified: branches/release/libs/chrono/doc/chrono.qbk
==============================================================================
--- branches/release/libs/chrono/doc/chrono.qbk (original)
+++ branches/release/libs/chrono/doc/chrono.qbk 2012-10-24 20:07:52 EDT (Wed, 24 Oct 2012)
@@ -636,10 +636,6 @@
* MSVC 10.0
-Cygwin 1.7 with
-
-* GCC 4.3.4
-
MinGW with
* GCC 4.5.0
@@ -649,12 +645,36 @@
* GCC 4.6.0
* GCC 4.6.0 -std=c++0x
+Ubuntu with
+* GCC 4.4.6
+* GCC 4.4.6 -std=c++0x
+* GCC 4.5.4
+* GCC 4.5.4 -std=c++0x
+* GCC 4.6.1
+* GCC 4.6.1 -std=c++0x
+* Intel 12.1.3
+* Intel 12.1.3 -std=c++0x
+
OsX with
* GCC 4.1.2
+* GCC 4.6.2
+* GCC 4.6.2 -std=c++0x
+* GCC 4.7.0
+* GCC 4.7.0 -std=c++0x
+* GCC 4.7.1
+* GCC 4.7.1 -std=c++0x
* clang 1.6
* clang 2.9
* clang 2.9 -std=c++0x
+* clang 3.0
+* clang 3.0 -std=c++0x
+* clang 3.1
+* clang 3.1 -std=c++0x
+* clang 3.1 -std=c++0x -stdlib=libc++
+* clang 3.2
+* clang 3.2 -std=c++11
+* clang 3.2 -std=c++11 -stdlib=libc++
The committed code is tested with much more compilers. There are two compilers (VACPP and Borland) that don't provide the needed features.
@@ -1397,7 +1417,21 @@
[endsect]
-[section:system_clock_time_point_io system_clock::time_point]
+[section:system_clock_time_point_io `system_clock::time_point`]
+
+[warning
+
+This 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:
+
+- [@http://svn.boost.org/trac/boost/ticket/7547 #7547] time_point<system_clock> input version 2 fails to compile
+
+- [@http://svn.boost.org/trac/boost/ticket/7546 #7546] time_point<system_clock> output version 2 fails to compile
+
+In this case the io operators behave like any time_point as defined in next section.
+
+In order to enable this features on compilers working with, you will need to define `BOOST_CHRONO_PROVIDES_DATE_IO_FOR_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].
@@ -2562,6 +2596,26 @@
These deprecated features will be only available until boost 1.58, that is you have 1 year and a half to move to the new features.
[endsect]
+
+
+[section:system_clock_time_point time_point<system_clock,D> specialization limitation]
+
+[warning
+
+The 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:
+
+- [@http://svn.boost.org/trac/boost/ticket/7547 #7547] time_point<system_clock> input version 2 fails to compile
+
+- [@http://svn.boost.org/trac/boost/ticket/7546 #7546] time_point<system_clock> output version 2 fails to compile
+
+In this case the io operators behave like any time_point as if the specialization was removed.
+
+In order to enable this features on compilers working with, you will need to define `BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT`.
+
+]
+
+[endsect]
+
[section:version Version]
`BOOST_CHRONO_VERSION` defines the Boost.Chrono version.
@@ -6284,6 +6338,8 @@
// system_clock I/O
+ #if defined BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT
+
template <class CharT, class Traits, class __Duration>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os,
@@ -6293,7 +6349,8 @@
basic_istream<CharT, Traits>&
operator>>(basic_istream<CharT, Traits>& is,
time_point<system_clock, __Duration>& tp);
-
+ #endif
+
// Other Clocks I/O
template <class CharT, class Traits, class __Clock, class __Duration>
@@ -6309,6 +6366,8 @@
}
}
+
+
[section:manip I/O Manipulators]
[section:time_fmt1 Non Member Function `time_fmt(__timezone)` ]
@@ -6340,6 +6399,21 @@
[section:streams I/O Streams Operations]
[section:system_clock `system_clock`]
+
+[warning
+
+The 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:
+
+- [@http://svn.boost.org/trac/boost/ticket/7547 #7547] time_point<system_clock> input version 2 fails to compile
+
+- [@http://svn.boost.org/trac/boost/ticket/7546 #7546] time_point<system_clock> output version 2 fails to compile
+
+In this case the io operators behave like any time_point as if the specialization was removed.
+
+In order to enable this features on compilers working with, you will need to define `BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT`.
+
+]
+
[section:op_out Non Member Function `operator<<()`]
template <class CharT, class Traits, class __Duration>
@@ -7253,7 +7327,7 @@
[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section [*Version 2.0.0, October 1, 2012 - 1.52] ]
+[section [*Version 2.0.0, October 23, 2012 - 1.52] ]
[*New Features:]
@@ -7275,6 +7349,7 @@
* [@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.
* [@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
* [@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
+* [@http://svn.boost.org/trac/boost/ticket/7542 #7542] Missing -lpthread in chrono/io tester Sandia-clang-trunk
[*Would not fix:]
@@ -7282,6 +7357,24 @@
* The neww io interface provided in version 2 solves this issue. You should move to the new version.
+[*Known bugs not fixed yet:]
+
+* [@http://svn.boost.org/trac/boost/ticket/7525 #7525] Wrong clock_string<system_clock>::since() on Windows
+
+[warning
+
+The 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:
+
+- [@http://svn.boost.org/trac/boost/ticket/7547 #7547] time_point<system_clock> input version 2 fails to compile
+
+- [@http://svn.boost.org/trac/boost/ticket/7546 #7546] time_point<system_clock> output version 2 fails to compile
+
+In this case the io operators behave like any time_point as if the specialization was removed.
+
+In order to enable this features on compilers working with, you will need to define `BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT`.
+
+]
+
[endsect] [/section [*Version 2.0.0] ]
[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
@@ -7795,8 +7888,8 @@
[heading For later releases]
* Include Stopwatches.
-* Include chrono::date as defined by Howard Hinnant [@http://home.roadrunner.com/~hinnant/bloomington/date.html here].
* Add User defined literals for some durations.
+* Include chrono::date as defined by Howard Hinnant [@http://home.roadrunner.com/~hinnant/bloomington/date.html here].
[endsect]
Modified: branches/release/libs/chrono/test/io/time_point_input.cpp
==============================================================================
--- branches/release/libs/chrono/test/io/time_point_input.cpp (original)
+++ branches/release/libs/chrono/test/io/time_point_input.cpp 2012-10-24 20:07:52 EDT (Wed, 24 Oct 2012)
@@ -20,6 +20,25 @@
BOOST_TEST( (tp == boost::chrono::time_point<Clock, D>(res)));
}
+#if BOOST_CHRONO_VERSION >= 2
+template <typename D>
+void test_good_system_clock(std::string str, D res)
+{
+ typedef boost::chrono::system_clock Clock;
+
+ std::istringstream in(str);
+ boost::chrono::time_point<Clock, D> tp;
+ in >> tp;
+ BOOST_TEST(in.eof());
+ BOOST_TEST(!in.fail());
+ std::cout << "Input= " << str << std::endl;
+ std::cout << "Expected= " << boost::chrono::time_point<Clock, D>(res) << std::endl;
+ std::cout << "Obtained= " << tp << std::endl;
+ std::cout << "Expected= " << boost::chrono::duration_cast<boost::chrono::nanoseconds>(boost::chrono::time_point<Clock, D>(res).time_since_epoch()).count() << std::endl;
+ std::cout << "Obtained= " << boost::chrono::duration_cast<boost::chrono::nanoseconds>(tp.time_since_epoch()).count() << std::endl;
+ BOOST_TEST( (tp == boost::chrono::time_point<Clock, D>(res)));
+}
+#endif
template <typename Clock, typename D>
void test_fail(const char* str, D)
{
@@ -71,7 +90,7 @@
test_good<Clock> ("5000 [1/30]seconds", duration<boost::int_least64_t, ratio<1, 30> > (5000));
test_good<Clock> ("5000 h", hours(5000));
-#if BOOST_CHRONO_VERSION==2
+#if BOOST_CHRONO_VERSION >= 2
test_good<Clock>("5000 min", minutes(5000));
#else
test_good<Clock> ("5000 m", minutes(5000));
@@ -91,6 +110,34 @@
}
+#if BOOST_CHRONO_VERSION >= 2
+void check_all_system_clock()
+{
+ using namespace boost::chrono;
+ using namespace boost;
+
+ test_good_system_clock ("1970-01-01 02:00:00.000000 +0000", hours(2));
+ test_good_system_clock ("1970-07-28 08:00:00.000000 +0000", hours(5000));
+ test_good_system_clock ("1970-01-04 11:20:00.000000 +0000", minutes(5000));
+ test_good_system_clock ("1970-01-01 01:23:20.000000 +0000", seconds(5000));
+ test_good_system_clock ("1970-01-01 00:00:01.000000 +0000", seconds(1));
+ test_good_system_clock ("1970-01-01 00:00:01.000000 +0000", seconds(1));
+ test_good_system_clock ("1969-12-31 23:59:59.000000 +0000", seconds(-1));
+ test_good_system_clock ("1970-01-01 00:00:00.000000 +0000", seconds(0));
+ test_good_system_clock ("1970-01-01 00:00:00.000000 +0000", seconds(0));
+ test_good_system_clock ("1970-01-01 00:00:05.000000 +0000", milliseconds(5000));
+ test_good_system_clock ("1970-01-01 00:00:00.005000 +0000", microseconds(5000));
+ test_good_system_clock ("1970-01-01 00:00:00.000005 +0000", nanoseconds(5000));
+ test_good_system_clock ("1970-01-01 00:08:20.000000 +0000", duration<boost::int_least64_t, deci> (5000));
+ test_good_system_clock ("1970-01-01 00:02:46.666667 +0000", duration<boost::int_least64_t, ratio<1, 30> > (5000));
+
+
+// test_fail<Clock> ("3001 ms", seconds(3));
+// test_fail_epoch<Clock> ("3001 ms", seconds(3));
+// test_fail_epoch<Clock> ("3001 ms since", seconds(3));
+
+}
+#endif
int main()
{
std::cout << "high_resolution_clock=" << std::endl;
@@ -99,9 +146,12 @@
std::cout << "steady_clock=" << std::endl;
check_all<boost::chrono::steady_clock> ();
#endif
- //std::cout << "system_clock=";
- //check_all<boost::chrono::system_clock>();
-
+ std::cout << "system_clock=" << std::endl;
+#if BOOST_CHRONO_VERSION >= 2 && defined BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT
+ check_all_system_clock();
+#else
+ check_all<boost::chrono::system_clock> ();
+#endif
#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
std::cout << "thread_clock="<< std::endl;
check_all<boost::chrono::thread_clock>();
Modified: branches/release/libs/chrono/test/io/time_point_output.cpp
==============================================================================
--- branches/release/libs/chrono/test/io/time_point_output.cpp (original)
+++ branches/release/libs/chrono/test/io/time_point_output.cpp 2012-10-24 20:07:52 EDT (Wed, 24 Oct 2012)
@@ -16,15 +16,32 @@
boost::chrono::time_point<Clock, D> tp(d);
out << tp;
BOOST_TEST(out.good());
+ //std::cout << "Expected= " << std::string(str) + boost::chrono::clock_string<Clock, char>::since() << std::endl;
+ //std::cout << "Obtained= " << out.str() << std::endl;
BOOST_TEST( (out.str() == std::string(str) + boost::chrono::clock_string<Clock, char>::since()));
}
+template <typename D>
+void test_good_prefix_system_clock(const char* str, D d)
+{
+ typedef boost::chrono::system_clock Clock;
+
+ std::ostringstream out;
+ boost::chrono::time_point<Clock, D> tp(d);
+ out << tp;
+ BOOST_TEST(out.good());
+
+ std::cout << "Expected= " << str << std::endl;
+ std::cout << "Obtained= " << out.str() << std::endl;
+ BOOST_TEST( (out.str() == std::string(str) ));
+}
+
template <typename Clock, typename D>
void test_good_symbol(const char* str, D d)
{
std::ostringstream out;
boost::chrono::time_point<Clock, D> tp(d);
-#if BOOST_CHRONO_VERSION==2
+#if BOOST_CHRONO_VERSION>=2
out << boost::chrono::duration_fmt(boost::chrono::duration_style::symbol) << tp;
#else
out << boost::chrono::duration_short << tp;
@@ -33,7 +50,21 @@
BOOST_TEST( (out.str() == std::string(str) + boost::chrono::clock_string<Clock, char>::since()));
}
-#if BOOST_CHRONO_VERSION==2
+#if BOOST_CHRONO_VERSION>=2
+template <typename D>
+void test_good_symbol_system_clock(const char* str, D d)
+{
+ typedef boost::chrono::system_clock Clock;
+
+ std::ostringstream out;
+ boost::chrono::time_point<Clock, D> tp(d);
+ out << boost::chrono::duration_fmt(boost::chrono::duration_style::symbol) << tp;
+ BOOST_TEST(out.good());
+ std::cout << "Expected= " << str << std::endl;
+ std::cout << "Obtained= " << out.str() << std::endl;
+ BOOST_TEST( (out.str() == std::string(str) ));
+}
+
template<typename Clock, typename D>
void test_good(const char* str, D d, boost::chrono::duration_style style)
{
@@ -43,6 +74,20 @@
BOOST_TEST(out.good());
BOOST_TEST((out.str() == std::string(str)+boost::chrono::clock_string<Clock,char>::since()));
}
+
+template<typename D>
+void test_good_system_clock(const char* str, D d, boost::chrono::duration_style style)
+{
+ typedef boost::chrono::system_clock Clock;
+
+ std::ostringstream out;
+ boost::chrono::time_point<Clock,D> tp(d);
+ out << boost::chrono::duration_fmt(style) << tp;
+ BOOST_TEST(out.good());
+ std::cout << "Expected= " << str << std::endl;
+ std::cout << "Obtained= " << out.str() << std::endl;
+ BOOST_TEST((out.str() == std::string(str) ));
+}
#endif
template <typename Clock>
@@ -51,7 +96,7 @@
using namespace boost::chrono;
using namespace boost;
-#if BOOST_CHRONO_VERSION==2
+#if BOOST_CHRONO_VERSION>=2
test_good<Clock>("2 hours", hours(2), duration_style::prefix);
test_good<Clock>("2 h", hours(2), duration_style::symbol);
#endif
@@ -69,7 +114,7 @@
test_good_prefix<Clock> ("2 [1/30]seconds", duration<boost::int_least64_t, ratio<1, 30> > (2));
test_good_symbol<Clock> ("2 h", hours(2));
-#if BOOST_CHRONO_VERSION==2
+#if BOOST_CHRONO_VERSION>=2
test_good_symbol<Clock>("2 min", minutes(2));
#else
test_good_symbol<Clock> ("2 m", minutes(2));
@@ -81,6 +126,36 @@
test_good_symbol<Clock> ("2 [1/30]s", duration<boost::int_least64_t, ratio<1, 30> > (2));
}
+#if BOOST_CHRONO_VERSION >= 2
+void check_all_system_clock()
+{
+ using namespace boost::chrono;
+ using namespace boost;
+
+ test_good_system_clock("1970-01-01 02:00:00.000000 +0000", hours(2), duration_style::prefix);
+ test_good_system_clock("1970-01-01 02:00:00.000000 +0000", hours(2), duration_style::symbol);
+
+ test_good_prefix_system_clock("1970-01-01 02:00:00.000000 +0000", hours(2));
+ test_good_prefix_system_clock("1970-01-01 00:02:00.000000 +0000", minutes(2));
+ test_good_prefix_system_clock("1970-01-01 00:00:02.000000 +0000", seconds(2));
+ test_good_prefix_system_clock("1970-01-01 00:00:01.000000 +0000", seconds(1));
+ test_good_prefix_system_clock("1969-12-31 23:59:59.000000 +0000", seconds(-1));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.000000 +0000", seconds(0));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.002000 +0000", milliseconds(2));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.000002 +0000", microseconds(2));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.000000 +0000", nanoseconds(2));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.200000 +0000", duration<boost::int_least64_t, deci> (2));
+ test_good_prefix_system_clock("1970-01-01 00:00:00.066667 +0000", duration<boost::int_least64_t, ratio<1, 30> > (2));
+
+ test_good_symbol_system_clock("1970-01-01 02:00:00.000000 +0000", hours(2));
+ test_good_symbol_system_clock("1970-01-01 00:02:00.000000 +0000", minutes(2));
+ test_good_symbol_system_clock("1970-01-01 00:00:02.000000 +0000", seconds(2));
+ test_good_symbol_system_clock("1970-01-01 00:00:00.002000 +0000", milliseconds(2));
+ test_good_symbol_system_clock("1970-01-01 00:00:00.000000 +0000", nanoseconds(2));
+ test_good_symbol_system_clock("1970-01-01 00:00:00.200000 +0000", duration<boost::int_least64_t, deci> (2));
+ test_good_symbol_system_clock("1970-01-01 00:00:00.066667 +0000", duration<boost::int_least64_t, ratio<1, 30> > (2));
+}
+#endif
int main()
{
@@ -90,8 +165,12 @@
std::cout << "steady_clock=" << std::endl;
check_all<boost::chrono::steady_clock> ();
#endif
- //std::cout << "system_clock=";
- //check_all<boost::chrono::system_clock>();
+ std::cout << "system_clock=" << std::endl;
+#if BOOST_CHRONO_VERSION >= 2 && defined BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT
+ check_all_system_clock();
+#else
+ check_all<boost::chrono::system_clock> ();
+#endif
#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
std::cout << "thread_clock="<< std::endl;
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