Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75346 - trunk/boost/chrono/io
From: vicente.botet_at_[hidden]
Date: 2011-11-06 15:54:24


Author: viboes
Date: 2011-11-06 15:54:21 EST (Sun, 06 Nov 2011)
New Revision: 75346
URL: http://svn.boost.org/trac/boost/changeset/75346

Log:
Chrono: refactor duration_get to allow more than 2 plural forms
Text files modified:
   trunk/boost/chrono/io/duration_get.hpp | 104 ++++++-----------
   trunk/boost/chrono/io/duration_io.hpp | 10 -
   trunk/boost/chrono/io/duration_units.hpp | 235 ++++++++++++++++++++++++---------------
   trunk/boost/chrono/io/time_point_io.hpp | 33 -----
   4 files changed, 182 insertions(+), 200 deletions(-)

Modified: trunk/boost/chrono/io/duration_get.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_get.hpp (original)
+++ trunk/boost/chrono/io/duration_get.hpp 2011-11-06 15:54:21 EST (Sun, 06 Nov 2011)
@@ -19,7 +19,6 @@
 #include <boost/chrono/detail/scan_keyword.hpp>
 #include <boost/assert.hpp>
 #include <locale>
-
 /**
  * Duration formatting facet for input.
  */
@@ -94,6 +93,7 @@
        * Type of character the facet is instantiated on.
        */
       typedef CharT char_type;
+ typedef std::basic_string<CharT> string_type;
       /**
        * Type of iterator used to scan the character buffer.
        */
@@ -225,7 +225,7 @@
                     return s;
                   }
                   loc_found=true;
- std::basic_string<CharT> pat = duration_units<CharT>::imbue_if_has_not(ios).get_pattern();
+ string_type pat = duration_units<CharT>::imbue_if_has_not(ios).get_pattern();
                   if (pattern+1 != pat_end)
                   pat.append(pattern+1, pat_end);
                   pattern = pat.data();
@@ -400,7 +400,7 @@
             err |= std::ios_base::failbit;
             return i;
           }
- const std::basic_string<CharT> units[] =
+ const string_type units[] =
           {
               facet.template get_plural_form<ratio<1> >(duration_style::prefix, 1),
               facet.template get_plural_form<ratio<1> >(duration_style::prefix, 0),
@@ -408,7 +408,7 @@
           };
           // FIXME is this necessary?????
           err = std::ios_base::goodbit;
- const std::basic_string<CharT>* k = chrono_detail::scan_keyword(i, e, units,
+ const string_type* k = chrono_detail::scan_keyword(i, e, units,
               units + sizeof (units) / sizeof (units[0]),
               //~ std::use_facet<std::ctype<CharT> >(loc),
               err);
@@ -424,74 +424,43 @@
         else
         {
           // parse SI name, short or long
+ std::size_t pfs = facet.get_plural_forms()+1;
+
+ // scoped_ptr ???
+ string_type* units= new string_type[19*pfs]();
+ string_type* it = units;
+ it = facet.fill_units(it, atto());
+ it = facet.fill_units(it, femto());
+ it = facet.fill_units(it, pico());
+ it = facet.fill_units(it, nano());
+ it = facet.fill_units(it, micro());
+ it = facet.fill_units(it, milli());
+ it = facet.fill_units(it, centi());
+ it = facet.fill_units(it, deci());
+ it = facet.fill_units(it, deca());
+ it = facet.fill_units(it, hecto());
+ it = facet.fill_units(it, kilo());
+ it = facet.fill_units(it, mega());
+ it = facet.fill_units(it, giga());
+ it = facet.fill_units(it, tera());
+ it = facet.fill_units(it, peta());
+ it = facet.fill_units(it, exa());
+ it = facet.fill_units(it, ratio<1>());
+ it = facet.fill_units(it, ratio<60>());
+ it = facet.fill_units(it, ratio<3600>());
+
+ string_type* units_end= units +19*pfs;
+
 
- const std::basic_string<CharT> units[] =
- {
- facet.template get_plural_form<atto>(duration_style::prefix, 1),
- facet.template get_plural_form<atto>(duration_style::prefix, 0),
- facet.template get_plural_form<atto>(duration_style::symbol, 0),
- facet.template get_plural_form<femto>(duration_style::prefix, 1),
- facet.template get_plural_form<femto>(duration_style::prefix, 0),
- facet.template get_plural_form<femto>(duration_style::symbol, 0),
- facet.template get_plural_form<pico>(duration_style::prefix, 1),
- facet.template get_plural_form<pico>(duration_style::prefix, 0),
- facet.template get_plural_form<pico>(duration_style::symbol, 0),
- facet.template get_plural_form<nano>(duration_style::prefix, 1),
- facet.template get_plural_form<nano>(duration_style::prefix, 0),
- facet.template get_plural_form<nano>(duration_style::symbol, 0),
- facet.template get_plural_form<micro>(duration_style::prefix, 1),
- facet.template get_plural_form<micro>(duration_style::prefix, 0),
- facet.template get_plural_form<micro>(duration_style::symbol, 0),
- facet.template get_plural_form<milli>(duration_style::prefix, 1),
- facet.template get_plural_form<milli>(duration_style::prefix, 0),
- facet.template get_plural_form<milli>(duration_style::symbol, 0),
- facet.template get_plural_form<centi>(duration_style::prefix, 1),
- facet.template get_plural_form<centi>(duration_style::prefix, 0),
- facet.template get_plural_form<centi>(duration_style::symbol, 0),
- facet.template get_plural_form<deci>(duration_style::prefix, 1),
- facet.template get_plural_form<deci>(duration_style::prefix, 0),
- facet.template get_plural_form<deci>(duration_style::symbol, 0),
- facet.template get_plural_form<deca>(duration_style::prefix, 1),
- facet.template get_plural_form<deca>(duration_style::prefix, 0),
- facet.template get_plural_form<deca>(duration_style::symbol, 0),
- facet.template get_plural_form<hecto>(duration_style::prefix, 1),
- facet.template get_plural_form<hecto>(duration_style::prefix, 0),
- facet.template get_plural_form<hecto>(duration_style::symbol, 0),
- facet.template get_plural_form<kilo>(duration_style::prefix, 1),
- facet.template get_plural_form<kilo>(duration_style::prefix, 0),
- facet.template get_plural_form<kilo>(duration_style::symbol, 0),
- facet.template get_plural_form<mega>(duration_style::prefix, 1),
- facet.template get_plural_form<mega>(duration_style::prefix, 0),
- facet.template get_plural_form<mega>(duration_style::symbol, 0),
- facet.template get_plural_form<giga>(duration_style::prefix, 1),
- facet.template get_plural_form<giga>(duration_style::prefix, 0),
- facet.template get_plural_form<giga>(duration_style::symbol, 0),
- facet.template get_plural_form<tera>(duration_style::prefix, 1),
- facet.template get_plural_form<tera>(duration_style::prefix, 0),
- facet.template get_plural_form<tera>(duration_style::symbol, 0),
- facet.template get_plural_form<peta>(duration_style::prefix, 1),
- facet.template get_plural_form<peta>(duration_style::prefix, 0),
- facet.template get_plural_form<peta>(duration_style::symbol, 0),
- facet.template get_plural_form<exa>(duration_style::prefix, 1),
- facet.template get_plural_form<exa>(duration_style::prefix, 0),
- facet.template get_plural_form<exa>(duration_style::symbol, 0),
- facet.template get_plural_form<ratio<1> >(duration_style::prefix, 1),
- facet.template get_plural_form<ratio<1> >(duration_style::prefix, 0),
- facet.template get_plural_form<ratio<1> >(duration_style::symbol, 0),
- facet.template get_plural_form<ratio<60> >(duration_style::prefix, 1),
- facet.template get_plural_form<ratio<60> >(duration_style::prefix, 0),
- facet.template get_plural_form<ratio<60> >(duration_style::symbol, 0),
- facet.template get_plural_form<ratio<3600> >(duration_style::prefix, 1),
- facet.template get_plural_form<ratio<3600> >(duration_style::prefix, 0),
- facet.template get_plural_form<ratio<3600> >(duration_style::symbol, 0)
- };
           err = std::ios_base::goodbit;
- const std::basic_string<CharT>* k = chrono_detail::scan_keyword(i, e, units,
- units + sizeof (units) / sizeof (units[0]),
+ const string_type* k = chrono_detail::scan_keyword(i, e, units,
+ units_end,
               //~ std::use_facet<std::ctype<CharT> >(loc),
               err);
 
- switch ( (k - units) / 3)
+ std::size_t index = (k - units) / pfs;
+ delete []units;
+ switch ( index )
           {
           case 0:
             rt = detail::rt_ratio(atto());
@@ -552,6 +521,7 @@
             break;
           default:
             err = std::ios_base::failbit;
+ std::cout << __FILE__ << ":" << __LINE__ << std::endl;
             return i;
           }
         }

Modified: trunk/boost/chrono/io/duration_io.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_io.hpp (original)
+++ trunk/boost/chrono/io/duration_io.hpp 2011-11-06 15:54:21 EST (Sun, 06 Nov 2011)
@@ -114,18 +114,15 @@
     };
 
     /**
- *
- * @param os
- * @param d
+ * duration stream inserter
+ * @param os the output stream
+ * @param d to value to insert
      * @return @c 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)
     {
- typename std::basic_ostream<CharT, Traits>::sentry ok(os);
- if (ok)
- {
         typedef std::basic_string<CharT, Traits> string_type;
         bool failed = false;
         try
@@ -168,7 +165,6 @@
           failed = true;
         }
         if (failed) os.setstate(std::ios_base::failbit | std::ios_base::badbit);
- }
       return os;
     }
 

Modified: trunk/boost/chrono/io/duration_units.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_units.hpp (original)
+++ trunk/boost/chrono/io/duration_units.hpp 2011-11-06 15:54:21 EST (Sun, 06 Nov 2011)
@@ -17,7 +17,6 @@
 #include <boost/chrono/io/ios_base_state.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <string>
-//#include <iostream>
 #include <ios>
 #include <locale>
 #include <algorithm>
@@ -139,8 +138,10 @@
     class duration_units: public std::locale::facet
     {
       static duration_units* global_;
+
     public:
       typedef CharT char_type;
+ typedef std::basic_string<CharT> string_type;
       typedef OutputIterator iter_type;
 
       static std::locale::id id;
@@ -276,7 +277,7 @@
        * @return the translation associated to the plural form given as parameter.
        */
       template <typename Period>
- typename enable_if<is_localizable<Period> , std::basic_string<CharT> >::type get_plural_form(
+ typename enable_if<is_localizable<Period> , string_type >::type get_plural_form(
           duration_style_type style, std::size_t pf) const
       {
         return do_get_plural_form(style, Period(), pf);
@@ -286,17 +287,60 @@
        *
        * @return the pattern to be used by default.
        */
- std::basic_string<CharT> get_pattern() const
+ string_type get_pattern() const
       {
         return do_get_pattern();
       }
 
+ template<typename Period>
+ inline string_type* fill_units(string_type* it, Period ) const
+ {
+ for (std::size_t pf=0; pf < get_plural_forms(); ++pf)
+ {
+ *it++ = get_plural_form<Period>(duration_style::prefix, pf);
+ }
+ *it++ = get_plural_form<Period>(duration_style::symbol, 0);
+ return it;
+ }
+
+ const string_type* get_units() const
+ {
+ string_type* units= new string_type[19*get_plural_forms()]();
+ string_type* it = units;
+ it = fill_units(it, atto());
+ it = fill_units(it, femto());
+ it = fill_units(it, pico());
+ it = fill_units(it, nano());
+ it = fill_units(it, micro());
+ it = fill_units(it, milli());
+ it = fill_units(it, centi());
+ it = fill_units(it, deci());
+ it = fill_units(it, deca());
+ it = fill_units(it, hecto());
+ it = fill_units(it, kilo());
+ it = fill_units(it, mega());
+ it = fill_units(it, giga());
+ it = fill_units(it, tera());
+ it = fill_units(it, peta());
+ it = fill_units(it, exa());
+ it = fill_units(it, ratio<1>());
+ it = fill_units(it, ratio<60>());
+ it = fill_units(it, ratio<3600>());
+
+ return units;
+ }
+ const string_type* get_units_end(const string_type* units) const
+ {
+ return units +19*get_plural_forms();
+ }
+
+
     protected:
 
       virtual ~duration_units() {}
       virtual duration_units<CharT, OutputIterator>* clone() const = 0;
 
- virtual std::basic_string<CharT> do_get_pattern() const=0;
+ virtual string_type do_get_pattern() const=0;
       virtual std::size_t do_get_plural_forms() const = 0;
       virtual std::size_t do_get_plural_form(int_least64_t value) const = 0;
 
@@ -341,25 +385,25 @@
       do_put(iter_type s, std::ios_base& ios, duration_style_type style, ratio<3600> , int_least64_t) const = 0;
 
       // used for input
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, atto, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, femto, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, pico, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, nano, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, micro, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, milli, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, centi, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, deci, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, ratio<1> , std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, deca, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, hecto, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, kilo, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, mega, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, giga, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, tera, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, peta, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, exa, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, ratio<60> , std::size_t pf) const = 0;
- virtual std::basic_string<CharT> do_get_plural_form(duration_style_type style, ratio<3600> , std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, atto, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, femto, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, pico, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, nano, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, micro, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, milli, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, centi, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, deci, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, ratio<1> , std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, deca, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, hecto, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, kilo, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, mega, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, giga, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, tera, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, peta, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, exa, std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, ratio<60> , std::size_t pf) const = 0;
+ virtual string_type do_get_plural_form(duration_style_type style, ratio<3600> , std::size_t pf) const = 0;
 
     };
 
@@ -367,14 +411,13 @@
     std::locale::id duration_units<CharT, OutputIterator>::id;
 
 
-
- ///////////////////////////
     // This class is used to define the strings for the default English
     template <typename CharT=char, class OutputIterator = std::ostreambuf_iterator<CharT> >
     class duration_units_default: public duration_units<CharT, OutputIterator>
     {
     public:
       typedef CharT char_type;
+ typedef std::basic_string<CharT> string_type;
       typedef OutputIterator iter_type;
 
       explicit duration_units_default(size_t refs = 0) :
@@ -404,128 +447,128 @@
         return (value == -1 || value == 1) ? 0 : 1;
       }
 
- std::basic_string<CharT> do_get_pattern() const
+ string_type do_get_pattern() const
       {
         static const CharT t[] =
         { '%', 'v', ' ', '%', 'u' };
- static const std::basic_string<CharT> pattern(t, t + sizeof (t) / sizeof (t[0]));
+ static const string_type pattern(t, t + sizeof (t) / sizeof (t[0]));
 
         return pattern;
       }
 
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, atto u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, femto u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, pico u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
 
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, nano u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, micro u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, milli u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, centi u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, deci u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base&, duration_style_type style, ratio<1> u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_plural_form(style, u, do_get_plural_form(value));
+ string_type str = do_get_plural_form(style, u, do_get_plural_form(value));
         return std::copy(str.begin(), str.end(), s);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, deca u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, hecto u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
 
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, kilo u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, mega u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, giga u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, tera u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, peta u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
       iter_type do_put(iter_type s, std::ios_base& ios, duration_style_type style, exa u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ string_type str = do_get_ratio_prefix(style, u);
         std::copy(str.begin(), str.end(), s);
         return do_put(s, ios, style, ratio<1> (), value);
       }
 
       iter_type do_put(iter_type s, std::ios_base&, duration_style_type style, ratio<60> u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_plural_form(style, u, do_get_plural_form(value));
+ string_type str = do_get_plural_form(style, u, do_get_plural_form(value));
         return std::copy(str.begin(), str.end(), s);
       }
 
       iter_type do_put(iter_type s, std::ios_base&, duration_style_type style, ratio<3600> u, int_least64_t value) const
       {
- std::basic_string<CharT> str = do_get_plural_form(style, u, do_get_plural_form(value));
+ string_type str = do_get_plural_form(style, u, do_get_plural_form(value));
         return std::copy(str.begin(), str.end(), s);
       }
 
@@ -541,37 +584,43 @@
         return do_put(s, ios, style, ratio<1> (), value);
       }
 
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, ratio<1> , std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, ratio<1> , std::size_t pf) const
       {
         static const CharT t[] =
         { 's' };
- static const std::basic_string<CharT> symbol(t, t + sizeof (t) / sizeof (t[0]));
+ static const string_type symbol(t, t + sizeof (t) / sizeof (t[0]));
         static const CharT u[] =
         { 's', 'e', 'c', 'o', 'n', 'd' };
- static const std::basic_string<CharT> singular(u, u + sizeof (u) / sizeof (u[0]));
+ static const string_type singular(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 's', 'e', 'c', 'o', 'n', 'd', 's' };
- static const std::basic_string<CharT> plural(v, v + sizeof (v) / sizeof (v[0]));
+ static const string_type plural(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style == duration_style::symbol) return symbol;
- if (pf == 0) return singular;
- if (pf == 1) return plural;
+ if (style == duration_style::symbol) {
+ return symbol;
+ }
+ if (pf == 0) {
+ return singular;
+ }
+ if (pf == 1) {
+ return plural;
+ }
         // assert
         throw "exception";
       }
 
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, ratio<60> , std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, ratio<60> , std::size_t pf) const
       {
         static const CharT t[] =
         { 'm', 'i', 'n' };
- static const std::basic_string<CharT> symbol(t, t + sizeof (t) / sizeof (t[0]));
+ static const string_type symbol(t, t + sizeof (t) / sizeof (t[0]));
 
         static const CharT u[] =
         { 'm', 'i', 'n', 'u', 't', 'e' };
- static const std::basic_string<CharT> singular(u, u + sizeof (u) / sizeof (u[0]));
+ static const string_type singular(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'm', 'i', 'n', 'u', 't', 'e', 's' };
- static const std::basic_string<CharT> plural(v, v + sizeof (v) / sizeof (v[0]));
+ static const string_type plural(v, v + sizeof (v) / sizeof (v[0]));
 
         if (style == duration_style::symbol) return symbol;
         if (pf == 0) return singular;
@@ -580,17 +629,17 @@
         throw "exception";
       }
 
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, ratio<3600> , std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, ratio<3600> , std::size_t pf) const
       {
         static const CharT t[] =
         { 'h' };
- static const std::basic_string<CharT> symbol(t, t + sizeof (t) / sizeof (t[0]));
+ static const string_type symbol(t, t + sizeof (t) / sizeof (t[0]));
         static const CharT u[] =
         { 'h', 'o', 'u', 'r' };
- static const std::basic_string<CharT> singular(u, u + sizeof (u) / sizeof (u[0]));
+ static const string_type singular(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'h', 'o', 'u', 'r', 's' };
- static const std::basic_string<CharT> plural(v, v + sizeof (v) / sizeof (v[0]));
+ static const string_type plural(v, v + sizeof (v) / sizeof (v[0]));
 
         if (style == duration_style::symbol) return symbol;
         if (pf == 0) return singular;
@@ -598,149 +647,149 @@
         // assert
         throw "exception";
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, atto u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, atto u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, femto u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, femto u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, pico u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, pico u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, nano u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, nano u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, micro u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, micro u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, milli u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, milli u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, centi u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, centi u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, deci u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, deci u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, deca u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, deca u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, hecto u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, hecto u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, kilo u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, kilo u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, mega u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, mega u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, giga u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, giga u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, tera u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, tera u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, peta u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, peta u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
- std::basic_string<CharT> do_get_plural_form(duration_style_type style, exa u, std::size_t pf) const
+ string_type do_get_plural_form(duration_style_type style, exa u, std::size_t pf) const
       {
         return do_get_ratio_prefix(style, u) + do_get_plural_form(style, ratio<1> (), pf);
       }
 
     protected:
 
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, atto) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, atto) const
       {
         if (style == duration_style::symbol) return ratio_string<atto,CharT>::symbol();
         return ratio_string<atto,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, femto) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, femto) const
       {
         if (style == duration_style::symbol) return ratio_string<femto,CharT>::symbol();
         return ratio_string<femto,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, pico) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, pico) const
       {
         if (style == duration_style::symbol) return ratio_string<pico,CharT>::symbol();
         return ratio_string<pico,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, nano) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, nano) const
       {
         if (style == duration_style::symbol) return ratio_string<nano,CharT>::symbol();
         return ratio_string<nano,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, micro) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, micro) const
       {
         if (style == duration_style::symbol) return ratio_string<micro,CharT>::symbol();
         return ratio_string<micro,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, milli) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, milli) const
       {
         if (style == duration_style::symbol) return ratio_string<milli,CharT>::symbol();
         return ratio_string<milli,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, centi) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, centi) const
       {
         if (style == duration_style::symbol) return ratio_string<centi,CharT>::symbol();
         return ratio_string<centi,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, deci) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, deci) const
       {
         if (style == duration_style::symbol) return ratio_string<deci,CharT>::symbol();
         return ratio_string<deci,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, deca) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, deca) const
       {
         if (style == duration_style::symbol) return ratio_string<deca,CharT>::symbol();
         return ratio_string<deca,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, hecto) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, hecto) const
       {
         if (style == duration_style::symbol) return ratio_string<hecto,CharT>::symbol();
         return ratio_string<hecto,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, kilo) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, kilo) const
       {
         if (style == duration_style::symbol) return ratio_string<kilo,CharT>::symbol();
         return ratio_string<kilo,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, mega) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, mega) const
       {
         if (style == duration_style::symbol) return ratio_string<mega,CharT>::symbol();
         return ratio_string<mega,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, giga) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, giga) const
       {
         if (style == duration_style::symbol) return ratio_string<giga,CharT>::symbol();
         return ratio_string<giga,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, tera) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, tera) const
       {
         if (style == duration_style::symbol) return ratio_string<tera,CharT>::symbol();
         return ratio_string<tera,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, peta) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, peta) const
       {
         if (style == duration_style::symbol) return ratio_string<peta,CharT>::symbol();
         return ratio_string<peta,CharT>::prefix();
       }
- virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style_type style, exa) const
+ virtual string_type do_get_ratio_prefix(duration_style_type style, exa) const
       {
         if (style == duration_style::symbol) return ratio_string<exa,CharT>::symbol();
         return ratio_string<exa,CharT>::prefix();

Modified: trunk/boost/chrono/io/time_point_io.hpp
==============================================================================
--- trunk/boost/chrono/io/time_point_io.hpp (original)
+++ trunk/boost/chrono/io/time_point_io.hpp 2011-11-06 15:54:21 EST (Sun, 06 Nov 2011)
@@ -218,10 +218,6 @@
         Duration>& tp)
     {
 
-#if 0
- return os << tp.time_since_epoch() << clock_string<Clock,
- CharT>::since();
-#else
         typedef std::basic_string<CharT, Traits> string_type;
         bool failed = false;
         try
@@ -265,7 +261,6 @@
         }
         if (failed) os.setstate(std::ios_base::failbit | std::ios_base::badbit);
         return os;
-#endif
     }
 
     template<class CharT, class Traits, class Clock, class Duration>
@@ -273,33 +268,6 @@
     operator>>(std::basic_istream<CharT, Traits>& is, time_point<Clock,
         Duration>& tp)
     {
-#if 0
- 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;
-#else
       std::ios_base::iostate err = std::ios_base::goodbit;
 
       try
@@ -330,7 +298,6 @@
       }
       if ( err ) is.setstate(err);
       return is;
-#endif
     }
 
 #ifndef BOOST_CHRONO_NO_UTC_TIMEPOINT


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