Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75331 - in trunk: boost/chrono boost/chrono/io_v1 libs/chrono/example libs/chrono/test libs/chrono/test/io
From: vicente.botet_at_[hidden]
Date: 2011-11-05 18:12:24


Author: viboes
Date: 2011-11-05 18:12:23 EDT (Sat, 05 Nov 2011)
New Revision: 75331
URL: http://svn.boost.org/trac/boost/changeset/75331

Log:
Chrono: restore io v1 and fix some error in it.
Added:
   trunk/boost/chrono/io_v1/
   trunk/boost/chrono/io_v1/chrono_io.hpp (contents, props changed)
Text files modified:
   trunk/boost/chrono/chrono_io.hpp | 6 +
   trunk/boost/chrono/config.hpp | 2
   trunk/libs/chrono/example/io_ex1.cpp | 13 ++
   trunk/libs/chrono/test/Jamfile.v2 | 157 ++++++++++++++++++++++++++++++++++-----
   trunk/libs/chrono/test/io/duration_input.cpp | 10 +-
   trunk/libs/chrono/test/io/duration_output.cpp | 23 +++--
   trunk/libs/chrono/test/io/time_point_input.cpp | 7 +
   trunk/libs/chrono/test/io/time_point_output.cpp | 17 +++-
   8 files changed, 193 insertions(+), 42 deletions(-)

Modified: trunk/boost/chrono/chrono_io.hpp
==============================================================================
--- trunk/boost/chrono/chrono_io.hpp (original)
+++ trunk/boost/chrono/chrono_io.hpp 2011-11-05 18:12:23 EDT (Sat, 05 Nov 2011)
@@ -13,7 +13,11 @@
 #ifndef BOOST_CHRONO_CHRONO_IO_HPP
 #define BOOST_CHRONO_CHRONO_IO_HPP
 
+#include <boost/chrono/config.hpp>
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
 #include <boost/chrono/io/time_point_io.hpp>
 #include <boost/chrono/io/duration_io.hpp>
-
+#else
+#include <boost/chrono/io_v1/chrono_io.hpp>
+#endif
 #endif // BOOST_CHRONO_CHRONO_IO_HPP

Modified: trunk/boost/chrono/config.hpp
==============================================================================
--- trunk/boost/chrono/config.hpp (original)
+++ trunk/boost/chrono/config.hpp 2011-11-05 18:12:23 EDT (Sat, 05 Nov 2011)
@@ -89,6 +89,8 @@
 #endif
 
 // deprecated i/o
+//#define BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
+
 #define BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
 #define BOOST_CHRONO_IO_USE_XALLOC
 #define BOOST_CHRONO_USES_DURATION_PUT

Added: trunk/boost/chrono/io_v1/chrono_io.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/chrono/io_v1/chrono_io.hpp 2011-11-05 18:12:23 EDT (Sat, 05 Nov 2011)
@@ -0,0 +1,601 @@
+
+// chrono_io
+//
+// (C) Copyright Howard Hinnant
+// (C) Copyright 2010 Vicente J. Botet Escriba
+// 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).
+//
+// This code was adapted by Vicente from Howard Hinnant's experimental work
+// on chrono i/o under lvm/libc++ to Boost
+
+#ifndef BOOST_CHRONO_IO_V1_CHRONO_IO_HPP
+#define BOOST_CHRONO_IO_V1_CHRONO_IO_HPP
+
+#include <boost/chrono/chrono.hpp>
+#include <boost/chrono/process_cpu_clocks.hpp>
+#include <boost/chrono/thread_clock.hpp>
+#include <boost/chrono/clock_string.hpp>
+#include <boost/ratio/ratio_io.hpp>
+#include <locale>
+#include <boost/type_traits/is_scalar.hpp>
+#include <boost/type_traits/is_signed.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/math/common_factor_rt.hpp>
+#include <boost/chrono/detail/scan_keyword.hpp>
+#include <boost/utility/enable_if.hpp>
+
+namespace boost
+{
+
+namespace chrono
+{
+
+template <class CharT>
+class duration_punct
+ : public std::locale::facet
+{
+public:
+ typedef std::basic_string<CharT> string_type;
+ enum {use_long, use_short};
+
+private:
+ bool use_short_;
+ string_type long_seconds_;
+ string_type long_minutes_;
+ string_type long_hours_;
+ string_type short_seconds_;
+ string_type short_minutes_;
+ string_type short_hours_;
+
+ template <class Period>
+ string_type short_name(Period) const
+ {return ::boost::ratio_string<Period, CharT>::short_name() + short_seconds_;}
+
+ string_type short_name(ratio<1>) const {return short_seconds_;}
+ string_type short_name(ratio<60>) const {return short_minutes_;}
+ string_type short_name(ratio<3600>) const {return short_hours_;}
+
+ template <class Period>
+ string_type long_name(Period) const
+ {return ::boost::ratio_string<Period, CharT>::long_name() + long_seconds_;}
+
+ string_type long_name(ratio<1>) const {return long_seconds_;}
+ string_type long_name(ratio<60>) const {return long_minutes_;}
+ string_type long_name(ratio<3600>) const {return long_hours_;}
+
+ void init_C();
+public:
+ static std::locale::id id;
+
+ explicit duration_punct(int use = use_long)
+ : use_short_(use==use_short) {init_C();}
+
+ 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
+ {return short_name(typename Period::type());}
+
+ template <class Period>
+ string_type long_name() const
+ {return long_name(typename Period::type());}
+
+ template <class Period>
+ string_type plural() const
+ {return long_name(typename Period::type());}
+
+ template <class Period>
+ string_type singular() const
+ {
+ return string_type(long_name(typename Period::type()), 0, long_name(typename Period::type()).size()-1);
+// string_type res;
+// res.assign(
+// long_name<Period>().data(),
+// long_name<Period>().data() + long_name<Period>().size()-1
+// );
+// return res;
+ }
+
+ template <class Period>
+ string_type name() const
+ {
+ if (use_short_) return short_name<Period>();
+ else {
+ return long_name<Period>();
+ }
+ }
+ template <class Period, class D>
+ string_type name(D v) const
+ {
+ if (use_short_) return short_name<Period>();
+ else
+ {
+ if (v==-1 || v==1)
+ return singular<Period>();
+ else
+ return plural<Period>();
+ }
+ }
+
+ bool is_short_name() const {return use_short_;}
+ bool is_long_name() const {return !use_short_;}
+};
+
+template <class CharT>
+std::locale::id
+duration_punct<CharT>::id;
+
+template <class CharT>
+void
+duration_punct<CharT>::init_C()
+{
+ short_seconds_ = CharT('s');
+ short_minutes_ = CharT('m');
+ short_hours_ = CharT('h');
+ const CharT s[] = {'s', 'e', 'c', 'o', 'n', 'd', 's'};
+ const CharT m[] = {'m', 'i', 'n', 'u', 't', 'e', 's'};
+ const CharT h[] = {'h', 'o', 'u', 'r', 's'};
+ long_seconds_.assign(s, s + sizeof(s)/sizeof(s[0]));
+ long_minutes_.assign(m, m + sizeof(m)/sizeof(m[0]));
+ long_hours_.assign(h, h + sizeof(h)/sizeof(h[0]));
+}
+
+template <class CharT>
+duration_punct<CharT>::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)
+ : use_short_(use==use_short),
+ long_seconds_(long_seconds),
+ long_minutes_(long_minutes),
+ long_hours_(long_hours),
+ short_seconds_(short_seconds),
+ short_minutes_(short_minutes),
+ short_hours_(short_hours)
+{}
+
+template <class CharT>
+duration_punct<CharT>::duration_punct(int use, const duration_punct& d)
+ : use_short_(use==use_short),
+ long_seconds_(d.long_seconds_),
+ long_minutes_(d.long_minutes_),
+ long_hours_(d.long_hours_),
+ short_seconds_(d.short_seconds_),
+ short_minutes_(d.short_minutes_),
+ short_hours_(d.short_hours_)
+{}
+
+template <class CharT, class Traits>
+std::basic_ostream<CharT, Traits>&
+duration_short(std::basic_ostream<CharT, Traits>& os)
+{
+ typedef duration_punct<CharT> Facet;
+ std::locale loc = os.getloc();
+ if (std::has_facet<Facet>(loc))
+ {
+ const Facet& f = std::use_facet<Facet>(loc);
+ if (f.is_long_name())
+ os.imbue(std::locale(loc, new Facet(Facet::use_short, f)));
+ }
+ else
+ os.imbue(std::locale(loc, new Facet(Facet::use_short)));
+ return os;
+}
+
+template <class CharT, class Traits>
+std::basic_ostream<CharT, Traits>&
+duration_long(std::basic_ostream<CharT, Traits>& os)
+{
+ typedef duration_punct<CharT> Facet;
+ std::locale loc = os.getloc();
+ if (std::has_facet<Facet>(loc))
+ {
+ const Facet& f = std::use_facet<Facet>(loc);
+ if (f.is_short_name())
+ os.imbue(std::locale(loc, new Facet(Facet::use_long, f)));
+ }
+ return os;
+}
+
+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)
+{
+ typedef duration_punct<CharT> Facet;
+ std::locale loc = os.getloc();
+ if (!std::has_facet<Facet>(loc))
+ os.imbue(std::locale(loc, new Facet));
+ const Facet& f = std::use_facet<Facet>(os.getloc());
+ return os << d.count() << ' ' << f.template name<Period>(d.count());
+}
+
+namespace chrono_detail {
+template <class Rep, bool = is_scalar<Rep>::value>
+struct duration_io_intermediate
+{
+ typedef Rep type;
+};
+
+template <class Rep>
+struct duration_io_intermediate<Rep, true>
+{
+ typedef typename mpl::if_c
+ <
+ is_floating_point<Rep>::value,
+ long double,
+ typename mpl::if_c
+ <
+ is_signed<Rep>::value,
+ long long,
+ unsigned long long
+ >::type
+ >::type type;
+};
+
+template <typename intermediate_type>
+typename enable_if<is_integral<intermediate_type>, bool>::type
+reduce(intermediate_type& r, unsigned long long& den, std::ios_base::iostate& err)
+{
+ typedef typename common_type<intermediate_type, unsigned long long>::type common_type_t;
+
+ // Reduce r * num / den
+ common_type_t t = math::gcd<common_type_t>(common_type_t(r), common_type_t(den));
+ r /= t;
+ den /= t;
+ if (den != 1)
+ {
+ // Conversion to Period is integral and not exact
+ err |= std::ios_base::failbit;
+ return false;
+ }
+ return true;
+}
+template <typename intermediate_type>
+typename disable_if<is_integral<intermediate_type>, bool>::type
+reduce(intermediate_type& , unsigned long long& , std::ios_base::iostate& )
+{
+ return true;
+}
+
+}
+
+template <class CharT, class Traits, class Rep, class Period>
+std::basic_istream<CharT, Traits>&
+operator>>(std::basic_istream<CharT, Traits>& is, duration<Rep, Period>& d)
+{
+ typedef duration_punct<CharT> Facet;
+ std::locale loc = is.getloc();
+ if (!std::has_facet<Facet>(loc))
+ is.imbue(std::locale(loc, new Facet));
+ loc = is.getloc();
+ const Facet& f = std::use_facet<Facet>(loc);
+ typedef typename chrono_detail::duration_io_intermediate<Rep>::type intermediate_type;
+ intermediate_type r;
+ // read value into r
+ is >> r;
+ if (is.good())
+ {
+ // now determine unit
+ typedef std::istreambuf_iterator<CharT, Traits> in_iterator;
+ in_iterator i(is);
+ in_iterator e;
+ if (i != e && *i == ' ') // mandatory ' ' after value
+ {
+ ++i;
+ if (i != e)
+ {
+ // unit is num / den (yet to be determined)
+ unsigned long long num = 0;
+ unsigned long long den = 0;
+ if (*i == '[')
+ {
+ // parse [N/D]s or [N/D]seconds format
+ ++i;
+ CharT x;
+ is >> num >> x >> den;
+ if (!is.good() || (x != '/'))
+ {
+ is.setstate(is.failbit);
+ return is;
+ }
+ i = in_iterator(is);
+ if (*i != ']')
+ {
+ is.setstate(is.failbit);
+ return is;
+ }
+ ++i;
+ const std::basic_string<CharT> units[] =
+ {
+ f.template singular<ratio<1> >(),
+ f.template plural<ratio<1> >(),
+ f.template short_name<ratio<1> >()
+ };
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ const std::basic_string<CharT>* k = chrono_detail::scan_keyword(i, e,
+ units, units + sizeof(units)/sizeof(units[0]),
+ //~ std::use_facet<std::ctype<CharT> >(loc),
+ err);
+ is.setstate(err);
+ switch ((k - units) / 3)
+ {
+ case 0:
+ break;
+ default:
+ is.setstate(err);
+ return is;
+ }
+ }
+ else
+ {
+ // parse SI name, short or long
+ const std::basic_string<CharT> units[] =
+ {
+ f.template singular<atto>(),
+ f.template plural<atto>(),
+ f.template short_name<atto>(),
+ f.template singular<femto>(),
+ f.template plural<femto>(),
+ f.template short_name<femto>(),
+ f.template singular<pico>(),
+ f.template plural<pico>(),
+ f.template short_name<pico>(),
+ f.template singular<nano>(),
+ f.template plural<nano>(),
+ f.template short_name<nano>(),
+ f.template singular<micro>(),
+ f.template plural<micro>(),
+ f.template short_name<micro>(),
+ f.template singular<milli>(),
+ f.template plural<milli>(),
+ f.template short_name<milli>(),
+ f.template singular<centi>(),
+ f.template plural<centi>(),
+ f.template short_name<centi>(),
+ f.template singular<deci>(),
+ f.template plural<deci>(),
+ f.template short_name<deci>(),
+ f.template singular<deca>(),
+ f.template plural<deca>(),
+ f.template short_name<deca>(),
+ f.template singular<hecto>(),
+ f.template plural<hecto>(),
+ f.template short_name<hecto>(),
+ f.template singular<kilo>(),
+ f.template plural<kilo>(),
+ f.template short_name<kilo>(),
+ f.template singular<mega>(),
+ f.template plural<mega>(),
+ f.template short_name<mega>(),
+ f.template singular<giga>(),
+ f.template plural<giga>(),
+ f.template short_name<giga>(),
+ f.template singular<tera>(),
+ f.template plural<tera>(),
+ f.template short_name<tera>(),
+ f.template singular<peta>(),
+ f.template plural<peta>(),
+ f.template short_name<peta>(),
+ f.template singular<exa>(),
+ f.template plural<exa>(),
+ f.template short_name<exa>(),
+ f.template singular<ratio<1> >(),
+ f.template plural<ratio<1> >(),
+ f.template short_name<ratio<1> >(),
+ f.template singular<ratio<60> >(),
+ f.template plural<ratio<60> >(),
+ f.template short_name<ratio<60> >(),
+ f.template singular<ratio<3600> >(),
+ f.template plural<ratio<3600> >(),
+ f.template short_name<ratio<3600> >()
+ };
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ const std::basic_string<CharT>* k = chrono_detail::scan_keyword(i, e,
+ units, units + sizeof(units)/sizeof(units[0]),
+ //~ std::use_facet<std::ctype<CharT> >(loc),
+ err);
+ is.setstate(err);
+ switch ((k - units) / 3)
+ {
+ case 0:
+ num = 1ULL;
+ den = 1000000000000000000ULL;
+ break;
+ case 1:
+ num = 1ULL;
+ den = 1000000000000000ULL;
+ break;
+ case 2:
+ num = 1ULL;
+ den = 1000000000000ULL;
+ break;
+ case 3:
+ num = 1ULL;
+ den = 1000000000ULL;
+ break;
+ case 4:
+ num = 1ULL;
+ den = 1000000ULL;
+ break;
+ case 5:
+ num = 1ULL;
+ den = 1000ULL;
+ break;
+ case 6:
+ num = 1ULL;
+ den = 100ULL;
+ break;
+ case 7:
+ num = 1ULL;
+ den = 10ULL;
+ break;
+ case 8:
+ num = 10ULL;
+ den = 1ULL;
+ break;
+ case 9:
+ num = 100ULL;
+ den = 1ULL;
+ break;
+ case 10:
+ num = 1000ULL;
+ den = 1ULL;
+ break;
+ case 11:
+ num = 1000000ULL;
+ den = 1ULL;
+ break;
+ case 12:
+ num = 1000000000ULL;
+ den = 1ULL;
+ break;
+ case 13:
+ num = 1000000000000ULL;
+ den = 1ULL;
+ break;
+ case 14:
+ num = 1000000000000000ULL;
+ den = 1ULL;
+ break;
+ case 15:
+ num = 1000000000000000000ULL;
+ den = 1ULL;
+ break;
+ case 16:
+ num = 1;
+ den = 1;
+ break;
+ case 17:
+ num = 60;
+ den = 1;
+ break;
+ case 18:
+ num = 3600;
+ den = 1;
+ break;
+ default:
+ is.setstate(err);
+ return is;
+ }
+ }
+ // unit is num/den
+ // r should be multiplied by (num/den) / Period
+ // Reduce (num/den) / Period to lowest terms
+ unsigned long long gcd_n1_n2 = math::gcd<unsigned long long>(num, Period::num);
+ unsigned long long gcd_d1_d2 = math::gcd<unsigned long long>(den, Period::den);
+ num /= gcd_n1_n2;
+ den /= gcd_d1_d2;
+ unsigned long long n2 = Period::num / gcd_n1_n2;
+ unsigned long long d2 = Period::den / gcd_d1_d2;
+ if (num > (std::numeric_limits<unsigned long long>::max)() / d2 ||
+ den > (std::numeric_limits<unsigned long long>::max)() / n2)
+ {
+ // (num/den) / Period overflows
+ is.setstate(is.failbit);
+ return is;
+ }
+ num *= d2;
+ den *= n2;
+
+ typedef typename common_type<intermediate_type, unsigned long long>::type common_type_t;
+
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ // num / den is now factor to multiply by r
+ if (!chrono_detail::reduce(r, den, err))
+ {
+ is.setstate(err);
+ return is;
+ }
+
+ if (r > ((duration_values<common_type_t>::max)() / num))
+ {
+ // Conversion to Period overflowed
+ is.setstate(is.failbit);
+ return is;
+ }
+ common_type_t t = r * num;
+ t /= den;
+
+ if (t > 0)
+ {
+ Rep pt = t;
+ if ( (duration_values<Rep>::max)() < pt)
+ {
+ // Conversion to Period overflowed
+ err |= std::ios_base::failbit;
+ return is;
+ }
+ }
+ // Success! Store it.
+ r = Rep(t);
+ d = duration<Rep, Period>(r);
+ }
+ else {
+ is.setstate(is.failbit | is.eofbit);
+ return is;
+ }
+ }
+ else
+ {
+ if (i == e)
+ is.setstate(is.eofbit);
+ is.setstate(is.failbit);
+ }
+ }
+ else {
+ is.setstate(is.failbit);
+ }
+ return is;
+}
+
+
+template <class CharT, class Traits, class Clock, class Duration>
+std::basic_ostream<CharT, Traits>&
+operator<<(std::basic_ostream<CharT, Traits>& os,
+ const time_point<Clock, Duration>& tp)
+{
+ return os << tp.time_since_epoch() << clock_string<Clock, CharT>::since();
+}
+
+template <class CharT, class Traits, class Clock, class Duration>
+std::basic_istream<CharT, Traits>&
+operator>>(std::basic_istream<CharT, Traits>& is,
+ time_point<Clock, Duration>& tp)
+{
+ Duration d;
+ is >> d;
+ if (is.good())
+ {
+ const std::basic_string<CharT> units=clock_string<Clock, CharT>::since();
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ typedef std::istreambuf_iterator<CharT, Traits> in_iterator;
+ in_iterator i(is);
+ in_iterator e;
+ std::ptrdiff_t k = chrono_detail::scan_keyword(i, e,
+ &units, &units + 1,
+ //~ std::use_facet<std::ctype<CharT> >(is.getloc()),
+ err) - &units;
+ if (k == 1)
+ {
+ // failed to read epoch string
+ is.setstate(err);
+ return is;
+ }
+ tp = time_point<Clock, Duration>(d);
+ }
+ else
+ is.setstate(is.failbit);
+ return is;
+}
+} // chrono
+
+}
+
+#endif // BOOST_CHRONO_CHRONO_IO_HPP

Modified: trunk/libs/chrono/example/io_ex1.cpp
==============================================================================
--- trunk/libs/chrono/example/io_ex1.cpp (original)
+++ trunk/libs/chrono/example/io_ex1.cpp 2011-11-05 18:12:23 EDT (Sat, 05 Nov 2011)
@@ -38,8 +38,11 @@
          << ClockTick(3) + nanoseconds(10) << '\n';
 
     cout << "\nSet cout to use short names:\n";
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
     cout << duration_fmt(duration_style::symbol);
-
+#else
+ cout << duration_short;
+#endif
     cout << "milliseconds(3) + microseconds(10) = "
          << milliseconds(3) + microseconds(10) << '\n';
 
@@ -50,15 +53,21 @@
          << ClockTick(3) + nanoseconds(10) << '\n';
 
     cout << "\nsystem_clock::now() = " << system_clock::now() << '\n';
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
     cout << "\nsystem_clock::now() = " << time_fmt(chrono::timezone::local) << system_clock::now() << '\n';
     cout << "\nsystem_clock::now() = " << time_fmt(chrono::timezone::local,"%Y/%m/%d") << system_clock::now() << '\n';
-
+#endif
 
 #ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
     cout << "steady_clock::now() = " << steady_clock::now() << '\n';
 #endif
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
     cout << "\nSet cout to use long names:\n" << cout << duration_fmt(duration_style::prefix)
          << "high_resolution_clock::now() = " << high_resolution_clock::now() << '\n';
+#else
+ cout << "\nSet cout to use long names:\n" << cout << duration_long
+ << "high_resolution_clock::now() = " << high_resolution_clock::now() << '\n';
+#endif
 #if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
     cout << "\nthread_clock::now() = " << thread_clock::now() << '\n';
 #endif

Modified: trunk/libs/chrono/test/Jamfile.v2
==============================================================================
--- trunk/libs/chrono/test/Jamfile.v2 (original)
+++ trunk/libs/chrono/test/Jamfile.v2 2011-11-05 18:12:23 EDT (Sat, 05 Nov 2011)
@@ -51,6 +51,7 @@
         : :
         :
             <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(sources[1]:B)_shared ]
     #[ run $(sources) ../build//boost_chrono/<link>static
     # : :
@@ -61,9 +62,40 @@
         : :
         : <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(sources[1]:B)_header ]
     ;
 }
+
+rule chrono-v1-v2-run ( sources )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
+ : $(sources[1]:B)_shared ]
+ [ run $(sources) ../build//boost_chrono/<link>static
+ : :
+ :
+ <library>/boost/system//boost_system
+ : v1_$(sources[1]:B)_static ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
+ : $(sources[1]:B)_header ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
+ : v1_$(sources[1]:B)_header ]
+ ;
+}
+
 rule chrono-run2 ( sources : name )
 {
     return
@@ -71,6 +103,7 @@
         : :
         :
             <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(name)_shared ]
     #[ run $(sources) ../build//boost_chrono/<link>static
     # : :
@@ -81,10 +114,59 @@
         : :
         : <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(name)_header ]
     ;
 }
 
+rule stopwatch-run ( sources + )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
+ : $(sources[1]:B)_shared ]
+ ;
+}
+
+rule stopwatch-run2 ( sources + : name )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
+ : $(name)_shared ]
+ ;
+}
+
+rule date-run ( sources + )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
+ : $(sources[1]:B)_shared ]
+ ;
+}
+
+rule date-run-2 ( sources + : name )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
+ : $(name)_shared ]
+ ;
+}
+
 
 rule chrono-run-mt ( sources )
 {
@@ -93,6 +175,7 @@
         : :
         :
             <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(sources[1]:B)_shared ]
     #[ run $(sources) ../build//boost_chrono/<link>static
     # : :
@@ -103,6 +186,7 @@
         : :
         : <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(sources[1]:B)_header ]
     ;
 }
@@ -113,6 +197,7 @@
         : :
         :
             <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(name)_shared ]
     #[ run $(sources) ../build//boost_chrono/<link>static
     # : :
@@ -123,6 +208,7 @@
         : :
         : <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(name)_header ]
     ;
 }
@@ -134,16 +220,19 @@
         : :
         :
             <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(sources[1]:B)_shared ]
     [ run $(sources)
         : :
         :
             <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(sources[1]:B)_static ]
     [ run $(sources)
         : :
         : <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(sources[1]:B)_header ]
     ;
 }
@@ -155,16 +244,19 @@
         : :
         :
             <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(name)_shared ]
     [ run $(sources)
         : :
         :
             <library>/boost/system//boost_system
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(name)_static ]
     [ run $(sources)
         : :
         : <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(name)_header ]
     ;
 }
@@ -176,10 +268,28 @@
         : :
         : <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(sources[1]:B)_header ]
     ;
 }
 
+rule chrono-v1-v2-run-header ( sources )
+{
+ return
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
+ : $(sources[1]:B)_header ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ : v1_$(sources[1]:B)header ]
+ ;
+}
+
 rule chrono-run-header2 ( sources : name )
 {
     return
@@ -187,6 +297,7 @@
         : :
         : <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(name)_header ]
     ;
 }
@@ -196,10 +307,12 @@
     return
     [ compile $(sources)
         :
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(sources[1]:B)_lib ]
     [ compile $(sources)
         : <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(sources[1]:B)_header ]
     ;
 }
@@ -209,10 +322,12 @@
     return
     [ compile $(sources)
         :
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(name)_lib ]
     [ compile $(sources)
         : <define>BOOST_CHRONO_HEADER_ONLY
            <define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ <define>BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
         : $(name)_header ]
     ;
 }
@@ -299,48 +414,48 @@
 
     test-suite "stopwatch"
         :
- [ chrono-run2 stopwatch/simple_stopwatch_pass.cpp : simple_stopwatch_pass ]
- [ chrono-run2 stopwatch/basic_stopwatch_pass.cpp : basic_stopwatch_pass ]
- [ chrono-run2 stopwatch/basic_stopwatch_last_lap_pass.cpp : basic_stopwatch_last_lap_pass ]
- [ chrono-run2 stopwatch/basic_stopwatch_laps_accumulator_set_pass.cpp : basic_stopwatch_laps_accumulator_set_pass ]
- [ chrono-run2 stopwatch/basic_stopwatch_laps_container_pass.cpp : basic_stopwatch_laps_container_pass ]
+ [ stopwatch-run2 stopwatch/simple_stopwatch_pass.cpp : simple_stopwatch_pass ]
+ [ stopwatch-run2 stopwatch/basic_stopwatch_pass.cpp : basic_stopwatch_pass ]
+ [ stopwatch-run2 stopwatch/basic_stopwatch_last_lap_pass.cpp : basic_stopwatch_last_lap_pass ]
+ [ stopwatch-run2 stopwatch/basic_stopwatch_laps_accumulator_set_pass.cpp : basic_stopwatch_laps_accumulator_set_pass ]
+ [ stopwatch-run2 stopwatch/basic_stopwatch_laps_container_pass.cpp : basic_stopwatch_laps_container_pass ]
 
- [ chrono-run2 stopwatch/suspendable_stopwatch_pass.cpp : suspendable_stopwatch_pass ]
+ [ stopwatch-run2 stopwatch/suspendable_stopwatch_pass.cpp : suspendable_stopwatch_pass ]
         ;
 
     test-suite "stopwatch_ex"
         :
- [ chrono-run ../example/stopwatch_example.cpp ]
+ [ stopwatch-run2 ../example/stopwatch_example.cpp : stopwatch_example ]
         ;
 
     test-suite "stopclock"
         :
- [ chrono-run2 stopwatch/simple_stopwatch_reporter_pass.cpp : simple_stopwatch_reporter_pass ]
- [ chrono-run2 stopwatch/basic_stopwatch_reporter_pass.cpp : basic_stopwatch_reporter_pass ]
- [ chrono-run2 stopwatch/basic_stopwatch_reporter_laps_accumulator_set_pass.cpp : basic_stopwatch_reporter_laps_accumulator_set_pass ]
+ [ stopwatch-run2 stopwatch/simple_stopwatch_reporter_pass.cpp : simple_stopwatch_reporter_pass ]
+ [ stopwatch-run2 stopwatch/basic_stopwatch_reporter_pass.cpp : basic_stopwatch_reporter_pass ]
+ [ stopwatch-run2 stopwatch/basic_stopwatch_reporter_laps_accumulator_set_pass.cpp : basic_stopwatch_reporter_laps_accumulator_set_pass ]
 
         ;
     test-suite "stopclock_ex"
         :
- [ chrono-run2-mt ../example/stopwatch_reporter_example.cpp : stopwatch_reporter_example ]
+ [ stopwatch-run2 ../example/stopwatch_reporter_example.cpp : stopwatch_reporter_example ]
         ;
 
     test-suite "io_ex"
         :
- [ chrono-run-mt ../example/io_ex1.cpp ]
- [ chrono-run-header ../example/io_ex2.cpp ]
- [ chrono-run ../example/io_ex3.cpp ]
- [ chrono-run ../example/io_ex4.cpp ]
- [ chrono-run ../example/io_ex5.cpp ]
- [ chrono-run ../example/french.cpp ]
+ [ chrono-v1-v2-run ../example/io_ex1.cpp ]
+ [ chrono-v1-v2-run-header ../example/io_ex2.cpp ]
+ [ chrono-v1-v2-run ../example/io_ex3.cpp ]
+ [ chrono-v1-v2-run ../example/io_ex4.cpp ]
+ [ chrono-v1-v2-run ../example/io_ex5.cpp ]
+ [ chrono-v1-v2-run ../example/french.cpp ]
         ;
 
     test-suite "io"
         :
- [ chrono-run-header io/duration_input.cpp ]
- [ chrono-run-header io/duration_output.cpp ]
- [ chrono-run-header io/time_point_input.cpp ]
- [ chrono-run-header io/time_point_output.cpp ]
+ [ chrono-v1-v2-run-header io/duration_input.cpp ]
+ [ chrono-v1-v2-run-header io/duration_output.cpp ]
+ [ chrono-v1-v2-run-header io/time_point_input.cpp ]
+ [ chrono-v1-v2-run-header io/time_point_output.cpp ]
         ;
 
     test-suite "win32"

Modified: trunk/libs/chrono/test/io/duration_input.cpp
==============================================================================
--- trunk/libs/chrono/test/io/duration_input.cpp (original)
+++ trunk/libs/chrono/test/io/duration_input.cpp 2011-11-05 18:12:23 EDT (Sat, 05 Nov 2011)
@@ -3,7 +3,7 @@
 // See http://www.boost.org/LICENSE_1_0.txt
 
 #include <boost/chrono/chrono_io.hpp>
-#include <boost/chrono/io/duration_units.hpp>
+//#include <boost/chrono/io/duration_units.hpp>
 #include <sstream>
 #include <boost/detail/lightweight_test.hpp>
 
@@ -13,7 +13,6 @@
   std::istringstream in(str);
   D d(0);
   in >> d;
- std::cerr << d << " * " << str << " * " << res << " st " << in.rdstate() << std::endl;
   BOOST_TEST(in.eof());
   BOOST_TEST(!in.fail());
   BOOST_TEST(d == res);
@@ -24,7 +23,6 @@
   std::istringstream in(str);
   D d(0);
   in >> d;
- std::cerr << d << " * " << str << " * " << res << " st " << in.rdstate() << std::endl;
   BOOST_TEST(in.eof());
   BOOST_TEST(!in.fail());
   BOOST_TEST(d == res);
@@ -37,7 +35,6 @@
     std::istringstream in(str);
     DFail d = DFail::zero();
     in >> d;
- std::cerr << d << " * " << str << " * " << res << " st " << in.rdstate() << std::endl;
     BOOST_TEST(in.fail());
     BOOST_TEST(d == DFail::zero());
   }
@@ -50,7 +47,6 @@
     std::istringstream in(str);
     D d = D::zero();
     in >> d;
- //std::cerr << d << " " << str << " " << res << std::endl;
     BOOST_TEST(!in.eof());
     BOOST_TEST(d == res);
   }
@@ -100,7 +96,11 @@
   test_good("5000 [1/30]seconds", duration<boost::int_least64_t, ratio<1, 30> > (5000));
   test_good("5000 [1/30]second", duration<boost::int_least64_t, ratio<1, 30> > (5000));
   test_good("5000 h", hours(5000));
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
   test_good("5000 min", minutes(5000));
+#else
+ test_good("5000 m", minutes(5000));
+#endif
   test_good("5000 s", seconds(5000));
   test_good("5000 ms", milliseconds(5000));
   test_good("5000 ns", nanoseconds(5000));

Modified: trunk/libs/chrono/test/io/duration_output.cpp
==============================================================================
--- trunk/libs/chrono/test/io/duration_output.cpp (original)
+++ trunk/libs/chrono/test/io/duration_output.cpp 2011-11-05 18:12:23 EDT (Sat, 05 Nov 2011)
@@ -20,10 +20,15 @@
 void test_good_symbol(const char* str, D d)
 {
   std::ostringstream out;
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
   out << boost::chrono::duration_fmt(boost::chrono::duration_style::symbol) << d;
+#else
+ out << boost::chrono::duration_short << d;
+#endif
   BOOST_TEST(out.good());
   BOOST_TEST(out.str() == str);
 }
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
 
 template<typename D>
 void test_good(const char* str, D d, boost::chrono::duration_style::type style)
@@ -50,25 +55,19 @@
   BOOST_TEST(out.str() == str2);
 }
 
+#endif
+
 int main()
 {
   using namespace boost::chrono;
   using namespace boost;
 
- test_good("5000 hours", hours(5000), duration_style::prefix);
- test_good("5000 h", hours(5000), duration_style::symbol);
-
   test_good_prefix("5000 hours", hours(5000));
   test_good_prefix("5000 minutes", minutes(5000));
   test_good_prefix("5000 seconds", seconds(5000));
   test_good_prefix("0 seconds", seconds(0));
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- test_good_prefix("1 seconds", seconds(1));
- test_good_prefix("-1 seconds", seconds(-1));
-#else
   test_good_prefix("1 second", seconds(1));
   test_good_prefix("-1 second", seconds(-1));
-#endif
   test_good_prefix("5000 milliseconds", milliseconds(5000));
   test_good_prefix("5000 microseconds", microseconds(5000));
   test_good_prefix("5000 nanoseconds", nanoseconds(5000));
@@ -76,14 +75,22 @@
   test_good_prefix("5000 [1/30]seconds", duration<boost::int_least64_t, ratio<1, 30> > (5000));
 
   test_good_symbol("5000 h", hours(5000));
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
   test_good_symbol("5000 min", minutes(5000));
+#else
+ test_good_symbol("5000 m", minutes(5000));
+#endif
   test_good_symbol("5000 s", seconds(5000));
   test_good_symbol("5000 ms", milliseconds(5000));
   test_good_symbol("5000 ns", nanoseconds(5000));
   test_good_symbol("5000 ds", duration<boost::int_least64_t, deci> (5000));
   test_good_symbol("5000 [1/30]s", duration<boost::int_least64_t, ratio<1, 30> > (5000));
 
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
+ test_good("5000 hours", hours(5000), duration_style::prefix);
+ test_good("5000 h", hours(5000), duration_style::symbol);
   test_state_saver("5000 h", "5000 h 5000 hours", hours(5000), duration_style::symbol);
+#endif
 
   return boost::report_errors();
 

Modified: trunk/libs/chrono/test/io/time_point_input.cpp
==============================================================================
--- trunk/libs/chrono/test/io/time_point_input.cpp (original)
+++ trunk/libs/chrono/test/io/time_point_input.cpp 2011-11-05 18:12:23 EDT (Sat, 05 Nov 2011)
@@ -59,7 +59,10 @@
   test_good<Clock>("5000 minutes", minutes(5000));
   test_good<Clock>("5000 seconds", seconds(5000));
   test_good<Clock>("1 seconds", seconds(1));
+ test_good<Clock>("1 second", seconds(1));
   test_good<Clock>("-1 seconds", seconds(-1));
+ test_good<Clock>("0 second", seconds(0));
+ test_good<Clock>("0 seconds", seconds(0));
   test_good<Clock>("5000 milliseconds", milliseconds(5000));
   test_good<Clock>("5000 microseconds", microseconds(5000));
   test_good<Clock>("5000 nanoseconds", nanoseconds(5000));
@@ -67,7 +70,11 @@
   test_good<Clock>("5000 [1/30]seconds", duration<boost::int_least64_t, ratio<1, 30> > (5000));
 
   test_good<Clock>("5000 h", hours(5000));
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
   test_good<Clock>("5000 min", minutes(5000));
+#else
+ test_good<Clock>("5000 m", minutes(5000));
+#endif
   test_good<Clock>("5000 s", seconds(5000));
   test_good<Clock>("5000 ms", milliseconds(5000));
   test_good<Clock>("5000 ns", nanoseconds(5000));

Modified: trunk/libs/chrono/test/io/time_point_output.cpp
==============================================================================
--- trunk/libs/chrono/test/io/time_point_output.cpp (original)
+++ trunk/libs/chrono/test/io/time_point_output.cpp 2011-11-05 18:12:23 EDT (Sat, 05 Nov 2011)
@@ -24,11 +24,16 @@
 {
   std::ostringstream out;
   boost::chrono::time_point<Clock,D> tp(d);
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
   out << boost::chrono::duration_fmt(boost::chrono::duration_style::symbol) << tp;
+#else
+ out << boost::chrono::duration_short << tp;
+#endif
   BOOST_TEST(out.good());
   BOOST_TEST((out.str() == std::string(str)+boost::chrono::clock_string<Clock,char>::since()));
 }
 
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
 template<typename Clock, typename D>
 void test_good(const char* str, D d, boost::chrono::duration_style::type style)
 {
@@ -38,6 +43,7 @@
   BOOST_TEST(out.good());
   BOOST_TEST((out.str() == std::string(str)+boost::chrono::clock_string<Clock,char>::since()));
 }
+#endif
 
 template<typename Clock>
 void check_all()
@@ -45,19 +51,16 @@
   using namespace boost::chrono;
   using namespace boost;
 
+#if defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
   test_good<Clock>("2 hours", hours(2), duration_style::prefix);
   test_good<Clock>("2 h", hours(2), duration_style::symbol);
+#endif
 
   test_good_prefix<Clock>("2 hours", hours(2));
   test_good_prefix<Clock>("2 minutes", minutes(2));
   test_good_prefix<Clock>("2 seconds", seconds(2));
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- test_good_prefix<Clock>("1 seconds", seconds(1));
- test_good_prefix<Clock>("-1 seconds", seconds(-1));
-#else
   test_good_prefix<Clock>("1 second", seconds(1));
   test_good_prefix<Clock>("-1 second", seconds(-1));
-#endif
   test_good_prefix<Clock>("0 seconds", seconds(0));
   test_good_prefix<Clock>("2 milliseconds", milliseconds(2));
   test_good_prefix<Clock>("2 microseconds", microseconds(2));
@@ -66,7 +69,11 @@
   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 defined BOOST_CHRONO_DONT_PROVIDE_DEPRECATED_IO_V1
   test_good_symbol<Clock>("2 min", minutes(2));
+#else
+ test_good_symbol<Clock>("2 m", minutes(2));
+#endif
   test_good_symbol<Clock>("2 s", seconds(2));
   test_good_symbol<Clock>("2 ms", milliseconds(2));
   test_good_symbol<Clock>("2 ns", nanoseconds(2));


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