Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75186 - in trunk/boost/chrono: . io
From: vicente.botet_at_[hidden]
Date: 2011-10-31 07:43:25


Author: viboes
Date: 2011-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
New Revision: 75186
URL: http://svn.boost.org/trac/boost/changeset/75186

Log:
Chrono: refactor the ios_base state+Add duration_put facet+refactor duration_units
Added:
   trunk/boost/chrono/io/duration_put.hpp (contents, props changed)
   trunk/boost/chrono/io/ios_base_state.hpp (contents, props changed)
   trunk/boost/chrono/io/timezone.hpp (contents, props changed)
Text files modified:
   trunk/boost/chrono/config.hpp | 7
   trunk/boost/chrono/io/duration_io.hpp | 525 ++++++++++---------
   trunk/boost/chrono/io/duration_style.hpp | 2
   trunk/boost/chrono/io/duration_unit_string.hpp | 128 ++--
   trunk/boost/chrono/io/time_point_io.hpp | 130 ----
   trunk/boost/chrono/io/translate.hpp | 23
   trunk/boost/chrono/io/unit_strings.hpp | 1013 +++++++++++++++++++++++----------------
   7 files changed, 950 insertions(+), 878 deletions(-)

Modified: trunk/boost/chrono/config.hpp
==============================================================================
--- trunk/boost/chrono/config.hpp (original)
+++ trunk/boost/chrono/config.hpp 2011-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
@@ -91,7 +91,8 @@
 // deprecated i/o
 #define BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
 #define BOOST_CHRONO_IO_USE_XALLOC
-#define BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL
+#define BOOST_CHRONO_USES_DURATION_PUT
+//#define BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL
 //#define BOOST_CHRONO_IS_LOCALIZABLE_TRANSLATE
 
 // unicode support ------------------------------//
@@ -102,7 +103,6 @@
 #define BOOST_CHRONO_HAS_UNICODE_SUPPORT 1
 #endif
 
-
 #if ! defined BOOST_NOEXCEPT
 #if defined(BOOST_NO_NOEXCEPT)
 #define BOOST_NOEXCEPT
@@ -111,7 +111,6 @@
 #endif
 #endif
 
-
 #ifdef BOOST_CHRONO_HEADER_ONLY
 #define BOOST_CHRONO_INLINE inline
 #define BOOST_CHRONO_STATIC
@@ -141,7 +140,6 @@
 #define BOOST_CHRONO_DECL
 #endif
 
-
 //#define BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
 
 // enable automatic library variant selection ------------------------------//
@@ -165,4 +163,3 @@
 #endif // auto-linking disabled
 #endif // BOOST_CHRONO_HEADER_ONLY
 #endif // BOOST_CHRONO_CONFIG_HPP
-

Modified: trunk/boost/chrono/io/duration_io.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_io.hpp (original)
+++ trunk/boost/chrono/io/duration_io.hpp 2011-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
@@ -22,44 +22,18 @@
 #include <boost/chrono/detail/scan_keyword.hpp>
 #include <boost/chrono/io/duration_style.hpp>
 #include <boost/chrono/io/duration_unit_string.hpp>
+#include <boost/chrono/io/ios_base_state.hpp>
 //#include <boost/format.hpp>
 #include <locale>
-
+#if defined BOOST_CHRONO_USES_DURATION_PUT
+#include <boost/chrono/io/duration_put.hpp>
+#endif
 namespace boost
 {
   namespace chrono
   {
 
- namespace detail {
-
- enum chrono_fmt_masks
- {
- duration_style_mask=1<<0, timezone_mask = 1<<1, registerd_callback_mask = 1<<2
- };
- inline int chrono_io_masks_index() {
- static const int v_ = std::ios_base::xalloc();
- return v_;
- }
- inline duration_style::type get_duration_style(std::ios_base & ios) {
- long iw = ios.iword(chrono_io_masks_index());
- return (iw & duration_style_mask) ? duration_style::symbol : duration_style::prefix;
- }
- inline void set_duration_style(std::ios_base& ios, duration_style::type style) {
- long& iw = ios.iword(chrono_io_masks_index());
- iw &= ~duration_style_mask;
- iw |= (style?duration_style_mask:0) ;
- }
- inline bool is_registerd(std::ios_base & ios) {
- long iw = ios.iword(chrono_io_masks_index());
- return (iw & registerd_callback_mask) ;
- }
- inline void set_registered(std::ios_base& ios) {
- long& iw = ios.iword(chrono_io_masks_index());
- iw |= registerd_callback_mask ;
- }
- }
-
- template<class CharT>
+ template <class CharT>
     class duration_punct: public std::locale::facet
     {
     public:
@@ -86,8 +60,7 @@
       template<class Period>
       string_type short_name(Period) const
       {
- return ::boost::ratio_string<Period, CharT>::short_name()
- + short_seconds_;
+ return ::boost::ratio_string<Period, CharT>::short_name() + short_seconds_;
       }
 
       string_type short_name(ratio<1> ) const
@@ -106,8 +79,7 @@
       template<class Period>
       string_type long_name(Period) const
       {
- return ::boost::ratio_string<Period, CharT>::long_name()
- + long_seconds_;
+ return ::boost::ratio_string<Period, CharT>::long_name() + long_seconds_;
       }
 
       string_type long_name(ratio<1> ) const
@@ -135,7 +107,7 @@
           int use = duration_style::prefix,
 #endif
           size_t refs = 0) :
- std::locale::facet(refs)
+ std::locale::facet(refs)
 #if ! defined BOOST_CHRONO_IO_USE_XALLOC
       , style_(duration_style::type(use))
 #endif
@@ -148,7 +120,7 @@
           int use,
 #endif
           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, size_t refs =
- 0);
+ 0);
 
       duration_punct(
 #if ! defined BOOST_CHRONO_IO_USE_XALLOC
@@ -181,8 +153,6 @@
       }
 #endif
 
-
-
 #if ! defined BOOST_CHRONO_IO_USE_XALLOC
       bool is_symbol() const BOOST_NOEXCEPT
       {
@@ -215,17 +185,17 @@
       string_type name() const
       {
         if (is_symbol())
- return short_name<Period> ();
+ return short_name<Period> ();
         else
- return long_name<Period> ();
+ return long_name<Period> ();
       }
       template<class Rep, class Period>
       string_type name(duration<Rep, Period> const&) const
       {
         if (is_symbol())
- return short_name<Period> ();
+ return short_name<Period> ();
         else
- return long_name<Period> ();
+ return long_name<Period> ();
       }
 
       bool is_short_name() const
@@ -239,7 +209,7 @@
 #endif
     };
 
- template<class CharT>
+ template <class CharT>
     std::locale::id duration_punct<CharT>::id;
 
 #if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
@@ -251,31 +221,29 @@
       short_minutes_ = CharT('m');
       short_hours_ = CharT('h');
       const CharT s[] =
- { 's', 'e', 'c', 'o', 'n', 'd', 's' };
+ { 's', 'e', 'c', 'o', 'n', 'd', 's'};
       const CharT m[] =
- { 'm', 'i', 'n', 'u', 't', 'e', 's' };
+ { 'm', 'i', 'n', 'u', 't', 'e', 's'};
       const CharT h[] =
- { 'h', 'o', 'u', 'r', 's' };
+ { '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(
 #if ! defined BOOST_CHRONO_IO_USE_XALLOC
         int use,
 #endif
         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, size_t refs) :
- std::locale::facet(refs),
+ std::locale::facet(refs),
 #if ! defined BOOST_CHRONO_IO_USE_XALLOC
- style_(duration_style::type(use)),
+ style_(duration_style::type(use)),
 #endif
- long_seconds_(long_seconds), long_minutes_(long_minutes),
- long_hours_(long_hours), short_seconds_(short_seconds),
- short_minutes_(short_minutes), short_hours_(short_hours)
+ long_seconds_(long_seconds), long_minutes_(long_minutes),
+ long_hours_(long_hours), short_seconds_(short_seconds),
+ short_minutes_(short_minutes), short_hours_(short_hours)
     {
     }
 
@@ -285,13 +253,13 @@
         int use,
 #endif
         const duration_punct& d, size_t refs) :
- std::locale::facet(refs),
+ std::locale::facet(refs),
 #if ! defined BOOST_CHRONO_IO_USE_XALLOC
- style_(duration_style::type(use)),
+ style_(duration_style::type(use)),
 #endif
- 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_)
+ 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>
@@ -304,9 +272,10 @@
       {
         const Facet& f = std::use_facet<Facet>(loc);
         if (f.is_prefix())
- os.imbue(std::locale(loc, new Facet(duration_style::symbol, f)));
- } else
- os.imbue(std::locale(loc, new Facet(duration_style::symbol)));
+ os.imbue(std::locale(loc, new Facet(duration_style::symbol, f)));
+ }
+ else
+ os.imbue(std::locale(loc, new Facet(duration_style::symbol)));
       return os;
     }
 
@@ -320,13 +289,12 @@
       {
         const Facet& f = std::use_facet<Facet>(loc);
         if (f.is_symbol())
- os.imbue(std::locale(loc, new Facet(duration_style::prefix, f)));
+ os.imbue(std::locale(loc, new Facet(duration_style::prefix, f)));
       }
       return os;
     }
 #endif
 
-
     /**
      * duration parameterized manipulator.
      */
@@ -338,7 +306,7 @@
       /**
        * explicit manipulator constructor from a @c duration_style
        */
- explicit duration_fmt(duration_style::type style) BOOST_NOEXCEPT
+ explicit duration_fmt(duration_style::type style)BOOST_NOEXCEPT
       : style_(style)
       {}
 
@@ -361,12 +329,12 @@
     /**
      * Change the duration_punc facet associated to the output stream depending on the duration_format style parameter.
      */
- template<class CharT, class Traits>
+ template <class CharT, class Traits>
     std::basic_ostream<CharT, Traits>&
     operator <<(std::basic_ostream<CharT, Traits>& os, duration_fmt d)
     {
 #if defined BOOST_CHRONO_IO_USE_XALLOC
- detail::set_duration_style(os, d.get_duration_style());
+ set_duration_style(os, d.get_duration_style());
 #else
       typedef duration_punct<CharT> Facet;
       std::locale loc = os.getloc();
@@ -374,9 +342,10 @@
       {
         const Facet& f = std::use_facet<Facet>(loc);
         if (f.get_duration_style()!=d.get_duration_style())
- os.imbue(std::locale(loc, new Facet(d.get_duration_style(), f)));
- } else
- os.imbue(std::locale(loc, new Facet(d.get_duration_style())));
+ os.imbue(std::locale(loc, new Facet(d.get_duration_style(), f)));
+ }
+ else
+ os.imbue(std::locale(loc, new Facet(d.get_duration_style())));
 #endif
       return os;
     }
@@ -384,12 +353,12 @@
     /**
      * Change the duration_punc facet associated to the input stream depending on the duration_format style parameter.
      */
- template<class CharT, class Traits>
+ template <class CharT, class Traits>
     std::basic_istream<CharT, Traits>&
     operator >>(std::basic_istream<CharT, Traits>& is, duration_fmt d)
     {
 #if defined BOOST_CHRONO_IO_USE_XALLOC
- detail::set_duration_style(is, d.get_duration_style());
+ set_duration_style(is, d.get_duration_style());
 #else
       typedef duration_punct<CharT> Facet;
       std::locale loc = is.getloc();
@@ -397,9 +366,10 @@
       {
         const Facet& f = std::use_facet<Facet>(loc);
         if (f.get_duration_style()!=d.get_duration_style())
- is.imbue(std::locale(loc, new Facet(d.get_duration_style(), f)));
- } else
- is.imbue(std::locale(loc, new Facet(d.get_duration_style())));
+ is.imbue(std::locale(loc, new Facet(d.get_duration_style(), f)));
+ }
+ else
+ is.imbue(std::locale(loc, new Facet(d.get_duration_style())));
 #endif
       return is;
     }
@@ -409,7 +379,7 @@
      *
      * See Boost.IO i/o state savers for a motivating compression.
      */
- template<typename CharT = char, typename Traits = std::char_traits<CharT> >
+ template <typename CharT = char, typename Traits = std::char_traits<CharT> >
     struct duration_style_io_saver
     {
 
@@ -424,16 +394,16 @@
        * Store a reference to the i/o stream and the value of the associated @c duration_style.
        */
       explicit duration_style_io_saver(state_type &s) :
- s_save_(s)
+ s_save_(s)
       {
 #if defined BOOST_CHRONO_IO_USE_XALLOC
- a_save_ = detail::get_duration_style(s_save_);
+ a_save_ = get_duration_style(s_save_);
 
 #else
         typedef duration_punct<CharT> Facet;
         std::locale loc = s_save_.getloc();
         if (!std::has_facet<Facet>(loc))
- s_save_.imbue(std::locale(loc, new Facet()));
+ s_save_.imbue(std::locale(loc, new Facet()));
 
         const Facet& f = std::use_facet<Facet>(s_save_.getloc());
         a_save_ = f.get_duration_style();
@@ -446,7 +416,7 @@
        * Stores a reference to the i/o stream and the value @c duration_style to restore given as parameter.
        */
       duration_style_io_saver(state_type &s, aspect_type new_value) :
- s_save_(s), a_save_(new_value)
+ s_save_(s), a_save_(new_value)
       {
       }
 
@@ -466,7 +436,7 @@
       void restore()
       {
 #if defined BOOST_CHRONO_IO_USE_XALLOC
- detail::set_duration_style(s_save_, a_save_);
+ set_duration_style(s_save_, a_save_);
 #else
         s_save_ << duration_fmt(a_save_);
 #endif
@@ -495,15 +465,50 @@
           std::locale loc = os.getloc();
 
           if (!std::has_facet<Facet>(loc))
- os.imbue(std::locale(loc, new Facet));
+ os.imbue(std::locale(loc, new Facet));
           const Facet& f = std::use_facet<Facet>(os.getloc());
           return os << d.count() << ' ' << f.template name<Rep,Period>(d);
 #else
-#if defined BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL
- return os << to_basic_string<CharT>(detail::get_duration_style(os), d, os.getloc());
+#if defined BOOST_CHRONO_USES_DURATION_PUT
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ try
+ {
+ typename std::basic_ostream<CharT, Traits>::sentry opfx(os);
+ if (opfx)
+ {
+ if (!std::has_facet<duration_put<CharT> >(os.getloc()))
+ {
+ os.imbue(std::locale(os.getloc(), new duration_put<CharT> ()));
+ }
+ if (std::use_facet<duration_put<CharT> >(os.getloc()) .put(os, os, d) .failed())
+ {
+ err = std::ios_base::badbit;
+ }
+ os.width(0);
+ }
+ }
+ catch (...)
+ {
+ bool flag = false;
+ try
+ {
+ os.setstate(std::ios_base::failbit);
+ }
+ catch (std::ios_base::failure )
+ {
+ flag = true;
+ }
+ if (flag) throw;
+ }
+ if (err) os.setstate(err);
+ return os;
+
+#elif defined BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL
+ return os
+ << to_basic_string<CharT> (get_duration_style(os), d, os.getloc());
 #elif defined BOOST_CHRONO_IS_LOCALIZABLE_TRANSLATE
 
- duration_style::type style = detail::get_duration_style(os);
+ duration_style::type style = get_duration_style(os);
           if (ratio_string_is_localizable<Period>())
           {
             std::cout << __FILE__ << ":"<< __LINE__ << ": " << std::endl;
@@ -511,29 +516,29 @@
             return os << basic_format<CharT>(
                 translated_duration_unit<CharT, Rep, Period>(os.getloc(), style==duration_style::prefix, d),
                 os.getloc()
- )
- % d.count();
+ )
+ % d.count();
           }
           else
           {
             std::cout << __FILE__ << ":"<< __LINE__ << ": " << std::endl;
- return os << to_basic_string<CharT>(detail::get_duration_style(os), d, os.getloc());
+ return os << to_basic_string<CharT>(get_duration_style(os), d, os.getloc());
             return os << basic_format<CharT>(
                 translated_duration_unit<CharT, ratio<1> >(os.getloc(), style==duration_style::prefix),
                 os.getloc()
- )
- % d.count()
- % ratio_string<Period, CharT>::symbol();
+ )
+ % d.count()
+ % ratio_string<Period, CharT>::symbol();
           }
 #else
- return os << d.count() << ' ' << duration_unit<CharT>(os.getloc(), detail::get_duration_style(os)==duration_style::prefix, d);
+ return os << d.count() << ' ' << duration_unit<CharT>(os.getloc(), get_duration_style(os)==duration_style::prefix, d);
 #endif
 #endif
 #else
           std::locale loc = os.getloc();
 
           if (!std::has_facet<Facet>(loc))
- os.imbue(std::locale(loc, new Facet));
+ os.imbue(std::locale(loc, new Facet));
           const Facet& f = std::use_facet<Facet>(os.getloc());
 
 #if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
@@ -547,8 +552,7 @@
         {
           failed = true;
         }
- if (failed)
- os.setstate(std::ios_base::failbit | std::ios_base::badbit);
+ if (failed) os.setstate(std::ios_base::failbit | std::ios_base::badbit);
 
       }
       return os;
@@ -565,17 +569,8 @@
       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;
+ 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;
       };
 
     }
@@ -588,11 +583,45 @@
       typedef duration_punct<CharT> Facet;
       std::locale loc = is.getloc();
       if (!std::has_facet<Facet>(loc))
- is.imbue(std::locale(loc, new Facet));
+ is.imbue(std::locale(loc, new Facet));
       loc = is.getloc();
       const Facet& f = std::use_facet<Facet>(loc);
 #endif
-#if defined BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL2
+#if defined BOOST_CHRONO_USES_DURATION_GET
+
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ try
+ {
+ typename std::basic_istream<CharT, Traits>::sentry ipfx(is);
+ if(ipfx)
+ {
+ if (!std::has_facet<duration_get<CharT> >(is.getloc()))
+ {
+ is.imbue(std::locale(is.getloc(), new duration_get<CharT>()));
+ }
+ std::use_facet<duration_get<CharT> >(is.getloc())
+ .get(is, std::istreambuf_iterator<CharT,Traits>()
+ ,is, err, d);
+ }
+ } // try
+
+ catch(...)
+ {
+ bool flag = FALSE;
+ try
+ {
+ is.setstate(std::ios_base::failbit);
+ }
+ catch( std::ios_base::failure )
+ {
+ flag= TRUE;
+ }
+ if ( flag ) throw;
+ }
+ if ( err ) is.setstate(err);
+ return is;
+
+#elif defined BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL2
 #elif defined BOOST_CHRONO_IS_LOCALIZABLE_TRANSLATE2
 #else
 
@@ -636,23 +665,23 @@
               const std::basic_string<CharT> units[] =
               {
 #if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- f.template long_name<ratio<1> >(),
- f.template short_name<ratio<1> >()
+ f.template long_name<ratio<1> >(),
+ f.template short_name<ratio<1> >()
 #else
- duration_unit<CharT>(is.getloc(), true, seconds(2)),
- duration_unit<CharT>(is.getloc(), false, seconds(1))
+ duration_unit<CharT> (is.getloc(), true, seconds(2)), duration_unit<CharT> (is.getloc(), false,
+ seconds(1))
 #endif
- };
+ };
               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]),
+ 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);
- switch ((k - units) / 2)
+ switch ( (k - units) / 2)
               {
- case 0:
+ case 0:
                 break;
- default:
+ default:
                 is.setstate(err);
                 return is;
               }
@@ -664,192 +693,192 @@
               const std::basic_string<CharT> units[] =
               {
 #if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- f.template long_name<atto>(),
- f.template short_name<atto>(),
- f.template long_name<femto>(),
- f.template short_name<femto>(),
- f.template long_name<pico>(),
- f.template short_name<pico>(),
- f.template long_name<nano>(),
- f.template short_name<nano>(),
- f.template long_name<micro>(),
- f.template short_name<micro>(),
- f.template long_name<milli>(),
- f.template short_name<milli>(),
- f.template long_name<centi>(),
- f.template short_name<centi>(),
- f.template long_name<deci>(),
- f.template short_name<deci>(),
- f.template long_name<deca>(),
- f.template short_name<deca>(),
- f.template long_name<hecto>(),
- f.template short_name<hecto>(),
- f.template long_name<kilo>(),
- f.template short_name<kilo>(),
- f.template long_name<mega>(),
- f.template short_name<mega>(),
- f.template long_name<giga>(),
- f.template short_name<giga>(),
- f.template long_name<tera>(),
- f.template short_name<tera>(),
- f.template long_name<peta>(),
- f.template short_name<peta>(),
- f.template long_name<exa>(),
- f.template short_name<exa>(),
- f.template long_name<ratio<1> >(),
- f.template short_name<ratio<1> >(),
- f.template long_name<ratio<60> >(),
- f.template short_name<ratio<60> >(),
- f.template long_name<ratio<3600> >(),
- f.template short_name<ratio<3600> >()
-#else
- duration_unit<CharT>(is.getloc(), true, duration<Rep, atto>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, atto>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, atto>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, femto>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, femto>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, femto>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, pico>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, pico>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, pico>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, nano>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, nano>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, nano>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, micro>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, micro>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, micro>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, milli>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, milli>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, milli>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, centi>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, centi>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, centi>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, deci>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, deci>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, deci>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, deca>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, deca>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, deca>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, hecto>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, hecto>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, hecto>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, kilo>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, kilo>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, kilo>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, mega>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, mega>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, mega>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, giga>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, giga>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, giga>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, giga>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, tera>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, giga>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, peta>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, peta>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, peta>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, exa>(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, exa>(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, exa>(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, ratio<1> >(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, ratio<1> >(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, ratio<1> >(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, ratio<60> >(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, ratio<60> >(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, ratio<60> >(1)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, ratio<3600> >(2)),
- duration_unit<CharT>(is.getloc(), true, duration<Rep, ratio<3600> >(1)),
- duration_unit<CharT>(is.getloc(), false, duration<Rep, ratio<3600> >(1)),
+ f.template long_name<atto>(),
+ f.template short_name<atto>(),
+ f.template long_name<femto>(),
+ f.template short_name<femto>(),
+ f.template long_name<pico>(),
+ f.template short_name<pico>(),
+ f.template long_name<nano>(),
+ f.template short_name<nano>(),
+ f.template long_name<micro>(),
+ f.template short_name<micro>(),
+ f.template long_name<milli>(),
+ f.template short_name<milli>(),
+ f.template long_name<centi>(),
+ f.template short_name<centi>(),
+ f.template long_name<deci>(),
+ f.template short_name<deci>(),
+ f.template long_name<deca>(),
+ f.template short_name<deca>(),
+ f.template long_name<hecto>(),
+ f.template short_name<hecto>(),
+ f.template long_name<kilo>(),
+ f.template short_name<kilo>(),
+ f.template long_name<mega>(),
+ f.template short_name<mega>(),
+ f.template long_name<giga>(),
+ f.template short_name<giga>(),
+ f.template long_name<tera>(),
+ f.template short_name<tera>(),
+ f.template long_name<peta>(),
+ f.template short_name<peta>(),
+ f.template long_name<exa>(),
+ f.template short_name<exa>(),
+ f.template long_name<ratio<1> >(),
+ f.template short_name<ratio<1> >(),
+ f.template long_name<ratio<60> >(),
+ f.template short_name<ratio<60> >(),
+ f.template long_name<ratio<3600> >(),
+ f.template short_name<ratio<3600> >()
+#else
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, atto> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, atto> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, atto> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, femto> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, femto> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, femto> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, pico> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, pico> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, pico> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, nano> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, nano> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, nano> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, micro> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, micro> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, micro> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, milli> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, milli> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, milli> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, centi> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, centi> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, centi> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, deci> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, deci> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, deci> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, deca> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, deca> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, deca> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, hecto> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, hecto> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, hecto> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, kilo> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, kilo> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, kilo> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, mega> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, mega> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, mega> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, giga> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, giga> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, giga> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, giga> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, tera> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, giga> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, peta> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, peta> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, peta> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, exa> (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, exa> (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, exa> (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<1> > (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<1> > (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, ratio<1> > (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<60> > (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<60> > (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, ratio<60> > (1)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<3600> > (2)),
+ duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<3600> > (1)),
+ duration_unit<CharT> (is.getloc(), false, duration<Rep, ratio<3600> > (1)),
 #endif
- };
+ };
               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]),
+ 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);
 #if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
               switch ((k - units) / 2)
 #else
- switch ((k - units) / 3)
+ switch ( (k - units) / 3)
 #endif
               {
- case 0:
+ case 0:
                 num = 1ULL;
                 den = 1000000000000000000ULL;
                 break;
- case 1:
+ case 1:
                 num = 1ULL;
                 den = 1000000000000000ULL;
                 break;
- case 2:
+ case 2:
                 num = 1ULL;
                 den = 1000000000000ULL;
                 break;
- case 3:
+ case 3:
                 num = 1ULL;
                 den = 1000000000ULL;
                 break;
- case 4:
+ case 4:
                 num = 1ULL;
                 den = 1000000ULL;
                 break;
- case 5:
+ case 5:
                 num = 1ULL;
                 den = 1000ULL;
                 break;
- case 6:
+ case 6:
                 num = 1ULL;
                 den = 100ULL;
                 break;
- case 7:
+ case 7:
                 num = 1ULL;
                 den = 10ULL;
                 break;
- case 8:
+ case 8:
                 num = 10ULL;
                 den = 1ULL;
                 break;
- case 9:
+ case 9:
                 num = 100ULL;
                 den = 1ULL;
                 break;
- case 10:
+ case 10:
                 num = 1000ULL;
                 den = 1ULL;
                 break;
- case 11:
+ case 11:
                 num = 1000000ULL;
                 den = 1ULL;
                 break;
- case 12:
+ case 12:
                 num = 1000000000ULL;
                 den = 1ULL;
                 break;
- case 13:
+ case 13:
                 num = 1000000000000ULL;
                 den = 1ULL;
                 break;
- case 14:
+ case 14:
                 num = 1000000000000000ULL;
                 den = 1ULL;
                 break;
- case 15:
+ case 15:
                 num = 1000000000000000000ULL;
                 den = 1ULL;
                 break;
- case 16:
+ case 16:
                 num = 1;
                 den = 1;
                 break;
- case 17:
+ case 17:
                 num = 60;
                 den = 1;
                 break;
- case 18:
+ case 18:
                 num = 3600;
                 den = 1;
                 break;
- default:
+ default:
                 is.setstate(err);
                 return is;
               }
@@ -863,8 +892,8 @@
             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)
+ 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);
@@ -887,7 +916,7 @@
                 return is;
               }
             }
- if (r > ((duration_values<common_type_t>::max)() / num))
+ if (r > ( (duration_values<common_type_t>::max)() / num))
             {
               // Conversion to Period overflowed
               is.setstate(is.failbit);
@@ -895,9 +924,10 @@
             }
             common_type_t t = r * num;
             t /= den;
- if (t>0) {
+ if (t > 0)
+ {
               Rep pt = t;
- if ((duration_values<Rep>::max)() < pt)
+ if ( (duration_values<Rep>::max)() < pt)
               {
                 // Conversion to Period overflowed
                 is.setstate(is.failbit);
@@ -906,20 +936,19 @@
             }
             // Success! Store it.
             r = Rep(t);
- d = duration<Rep, Period>(r);
+ d = duration<Rep, Period> (r);
           }
           else
- is.setstate(is.failbit | is.eofbit);
+ is.setstate(is.failbit | is.eofbit);
         }
         else
         {
- if (i == e)
- is.setstate(is.eofbit);
+ if (i == e) is.setstate(is.eofbit);
           is.setstate(is.failbit);
         }
       }
       else
- is.setstate(is.failbit);
+ is.setstate(is.failbit);
 #endif
       return is;
     }

Added: trunk/boost/chrono/io/duration_put.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/chrono/io/duration_put.hpp 2011-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
@@ -0,0 +1,201 @@
+//
+// (C) Copyright 2011 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).
+//
+
+#ifndef BOOST_CHRONO_IO_DURATION_PUT_HPP
+#define BOOST_CHRONO_IO_DURATION_PUT_HPP
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/io/unit_strings.hpp>
+#include <locale>
+
+namespace boost
+{
+ namespace chrono
+ {
+
+ template <class CharT, class OutputIterator = std::ostreambuf_iterator<CharT> >
+ class duration_put: public std::locale::facet
+ {
+ public:
+ typedef CharT char_type;
+ typedef OutputIterator iter_type;
+
+ /**
+ * Facet constructor.
+ * @param refs
+ */
+ explicit duration_put(size_t refs = 0) :
+ std::locale::facet(refs)
+ {
+ }
+
+ /**
+ *
+ * @param s
+ * @param ios
+ * @param d
+ * @param pattern
+ * @param pat_end
+ *
+ * @Effects Steps through the sequence from @c pattern to @c pat_end,
+ * identifying characters that are part of a pattern sequence. Each character
+ * that is not part of a pattern sequence is written to @c s immediately, and
+ * each pattern sequence, as it is identified, results in a call to
+ * @c do_put_value or @c do_put_unit;
+ * thus, pattern elements and other characters are interleaved in the output
+ * in the order in which they appear in the pattern. Pattern sequences are
+ * identified by converting each character @c c to a @c char value as if by
+ * @c ct.narrow(c,0), where @c ct is a reference to @c ctype<charT> obtained from
+ * @c ios.getloc(). The first character of each sequence is equal to @c Õ%Õ,
+ * followed by a pattern specifier character @c spec, which can be @c 'v' for
+ * the duration value or @c 'u' for the duration unit. .
+ * For each valid pattern sequence identified, calls
+ * <c>do_put_value(s, ios, d)</c> or <c>do_put_unit(s, ios, d)</c>.
+ *
+ * @Returns: An iterator pointing immediately after the last character produced.
+ */
+ template <typename Rep, typename Period>
+ iter_type put(iter_type s, std::ios_base& ios, duration<Rep, Period> const& d, const CharT* pattern,
+ const CharT* pat_end) const
+ {
+ if (!std::has_facet<duration_units<CharT> >(ios.getloc())) ios.imbue(
+ std::locale(ios.getloc(), new duration_units_default<CharT> ()));
+
+ for (; pattern != pat_end; ++pattern)
+ {
+ if ( (*pattern != '%') || ( (pattern + 1) == pat_end) || (!std::strchr("uvx", * (pattern + 1))))
+ {
+ *s++ = *pattern;
+ }
+ else
+ {
+ ++pattern;
+ switch (*pattern)
+ {
+ case 'v':
+ std::use_facet<std::num_put<CharT, iter_type> >(ios.getloc()).put(s, ios, ' ',
+ static_cast<long int> (d.count()));
+ break;
+ case 'u':
+ {
+ std::use_facet<duration_units<CharT> >(ios.getloc()).put(s, ios, d);
+ break;
+ }
+ case 'x':
+ {
+ std::basic_string<CharT> pat = std::use_facet<duration_units<CharT> >(ios.getloc()).get_pattern();
+ pattern = pat.data();
+ pat_end = pattern + pat.size();
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ return s;
+ }
+ template <typename Rep, typename Period>
+ iter_type put(iter_type s, std::ios_base& ios, duration<Rep, Period> const& d) const
+ {
+ if (!std::has_facet<duration_units<CharT> >(ios.getloc())) ios.imbue(
+ std::locale(ios.getloc(), new duration_units_default<CharT> ()));
+
+ std::basic_string<CharT> str = std::use_facet<duration_units<CharT> >(ios.getloc()).get_pattern();
+ return put(s, ios, d, str.data(), str.data() + str.size());
+ }
+
+ /**
+ *
+ * @param s
+ * @param ios
+ * @param d
+ * @param pattern
+ * @Effects Calls do_put_value(s, f, d).
+ * @Returns: An iterator pointing immediately after the last character produced.
+ */
+ template <typename Rep, typename Period>
+ iter_type put_value(iter_type s, std::ios_base& ios, duration<Rep, Period> const& d) const
+ {
+ do_put_value(s, ios, d);
+ }
+
+ /**
+ *
+ * @param s
+ * @param ios
+ * @param d
+ * @param pattern
+ * @Effects Calls do_put_unit(s, f, d).
+ * @Returns: An iterator pointing immediately after the last character produced.
+ */
+ template <typename Rep, typename Period>
+ iter_type put_unit(iter_type s, std::ios_base& ios, duration<Rep, Period> const& d) const
+ {
+ do_put_unit(s, ios, d);
+ }
+
+ /**
+ * Unique identifier for this type of facet.
+ */
+ static std::locale::id id;
+ protected:
+ /**
+ *
+ */
+ ~duration_put()
+ {
+ }
+
+ // /**
+ // *
+ // * @param s
+ // * @param ios
+ // * @param d
+ // * @param pattern
+ // * @Effects: Formats the count() the parameter d into characters
+ // * placed on the output sequence s.
+ // * @Returns: An iterator pointing immediately after the last character produced.
+ // */
+ // virtual iter_type do_put_value(iter_type s, std::ios_base& ios, Rep d) const
+ // {
+ // stringstream str(ios.getloc());
+ // str << d.days_.count();
+ // const CharT* b = str.str().data();
+ // const CharT* e = b + str.str().size();
+ // std::copy(b, e, s);
+ // return s;
+ // }
+ // /**
+ // *
+ // * @param s
+ // * @param ios
+ // * @param d
+ // * @param pattern
+ // * @Effects: Formats the unit of the parameter d into characters
+ // * placed on the output sequence s. The unit is obtained calling to the duration_unit<CharT> facet to_string()
+ // * @Returns: An iterator pointing immediately after the last character produced.
+ // */
+ // virtual iter_type do_put_unit(iter_type s, std::ios_base& ios, duration<Rep,
+ // Period> const& d) const
+ // {
+ // // retrieve duration_units facet
+ // // get string
+ // std::basic_string<CharT> str;
+ // const CharT* b = str.data();
+ // const CharT* e = b + str.size();
+ // std::copy(b, e, s);
+ // }
+ };
+
+ template <class CharT, class OutputIterator>
+ std::locale::id duration_put<CharT, OutputIterator>::id;
+
+ } // chrono
+} // boost
+
+#endif // BOOST_CHRONO_CHRONO_IO_HPP

Modified: trunk/boost/chrono/io/duration_style.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_style.hpp (original)
+++ trunk/boost/chrono/io/duration_style.hpp 2011-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
@@ -29,6 +29,8 @@
         prefix, symbol
       };
     };
+ typedef duration_style::type duration_style_type;
+
 
   } // chrono
 

Modified: trunk/boost/chrono/io/duration_unit_string.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_unit_string.hpp (original)
+++ trunk/boost/chrono/io/duration_unit_string.hpp 2011-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
@@ -21,16 +21,24 @@
 namespace boost
 {
   template <>
- struct ratio_string_is_localizable<ratio<60> > : true_type {};
+ struct ratio_string_is_localizable<ratio<60> > : true_type
+ {
+ };
 
   template <>
- struct ratio_string_id<ratio<60> > : integral_constant<int,60> {};
+ struct ratio_string_id<ratio<60> > : integral_constant<int, 60>
+ {
+ };
 
   template <>
- struct ratio_string_is_localizable<ratio<3600> > : true_type {};
+ struct ratio_string_is_localizable<ratio<3600> > : true_type
+ {
+ };
 
   template <>
- struct ratio_string_id<ratio<3600> > : integral_constant<int,3600> {};
+ struct ratio_string_id<ratio<3600> > : integral_constant<int, 3600>
+ {
+ };
 
   namespace chrono
   {
@@ -41,9 +49,8 @@
       static std::basic_string<CharT> name()
       {
         static const CharT u[] =
- { '%', '1', '%', ' '};
- static const std::basic_string<CharT> str(u, u + sizeof(u)
- / sizeof(u[0]));
+ { '%', '1', '%', ' ' };
+ static const std::basic_string<CharT> str(u, u + sizeof (u) / sizeof (u[0]));
         return str;
       }
     };
@@ -53,15 +60,12 @@
       static std::basic_string<CharT> name()
       {
         static const CharT u[] =
- { '%', '2', '%'};
- static const std::basic_string<CharT> str(u, u + sizeof(u)
- / sizeof(u[0]));
+ { '%', '2', '%' };
+ static const std::basic_string<CharT> str(u, u + sizeof (u) / sizeof (u[0]));
         return str;
       }
     };
 
-
-
     template <class Period, class CharT>
     struct duration_unit_strings
     {
@@ -69,42 +73,38 @@
       {
         static const CharT u[] =
         { 's', 'e', 'c', 'o', 'n', 'd', 's' };
- static const std::basic_string<CharT> suffix(u, u + sizeof(u)
- / sizeof(u[0]));
- return ::boost::ratio_string<Period, CharT>::prefix()+suffix;
+ static const std::basic_string<CharT> suffix(u, u + sizeof (u) / sizeof (u[0]));
+ return ::boost::ratio_string<Period, CharT>::prefix() + suffix;
       }
       static std::basic_string<CharT> singular()
       {
         static const CharT u[] =
         { 's', 'e', 'c', 'o', 'n', 'd' };
- static const std::basic_string<CharT> suffix(u, u + sizeof(u)
- / sizeof(u[0]));
- return ::boost::ratio_string<Period, CharT>::prefix()+suffix;
+ static const std::basic_string<CharT> suffix(u, u + sizeof (u) / sizeof (u[0]));
+ return ::boost::ratio_string<Period, CharT>::prefix() + suffix;
       }
       static std::basic_string<CharT> symbol()
       {
         static const std::basic_string<CharT> str(1, 's');
- return ::boost::ratio_string<Period, CharT>::symbol()+str;
+ return ::boost::ratio_string<Period, CharT>::symbol() + str;
       }
     };
 
     template <class CharT>
- struct duration_unit_strings<ratio<1>, CharT >
+ struct duration_unit_strings<ratio<1> , CharT>
     {
       static std::basic_string<CharT> plural()
       {
         static const CharT u[] =
         { 's', 'e', 'c', 'o', 'n', 'd', 's' };
- static const std::basic_string<CharT> suffix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> suffix(u, u + sizeof (u) / sizeof (u[0]));
         return suffix;
       }
       static std::basic_string<CharT> singular()
       {
         static const CharT u[] =
         { 's', 'e', 'c', 'o', 'n', 'd' };
- static const std::basic_string<CharT> suffix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> suffix(u, u + sizeof (u) / sizeof (u[0]));
         return suffix;
       }
       static std::basic_string<CharT> symbol()
@@ -115,51 +115,46 @@
     };
 
     template <class CharT>
- struct duration_unit_strings<ratio<60>, CharT >
+ struct duration_unit_strings<ratio<60> , CharT>
     {
       static std::basic_string<CharT> plural()
       {
         static const CharT u[] =
         { 'm', 'i', 'n', 'u', 't', 'e', 's' };
- static const std::basic_string<CharT> str(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> str(u, u + sizeof (u) / sizeof (u[0]));
         return str;
       }
       static std::basic_string<CharT> singular()
       {
         static const CharT u[] =
         { 'm', 'i', 'n', 'u', 't', 'e' };
- static const std::basic_string<CharT> str(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> str(u, u + sizeof (u) / sizeof (u[0]));
         return str;
       }
       static std::basic_string<CharT> symbol()
       {
         static const CharT u[] =
         { 'm', 'i', 'n' };
- static const std::basic_string<CharT> str(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> str(u, u + sizeof (u) / sizeof (u[0]));
         return str;
       }
     };
 
     template <class CharT>
- struct duration_unit_strings<ratio<3600>, CharT >
+ struct duration_unit_strings<ratio<3600> , CharT>
     {
       static std::basic_string<CharT> plural()
       {
         static const CharT u[] =
         { 'h', 'o', 'u', 'r', 's' };
- static const std::basic_string<CharT> str(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> str(u, u + sizeof (u) / sizeof (u[0]));
         return str;
       }
       static std::basic_string<CharT> singular()
       {
         static const CharT u[] =
         { 'h', 'o', 'u', 'r' };
- static const std::basic_string<CharT> str(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> str(u, u + sizeof (u) / sizeof (u[0]));
         return str;
       }
       static std::basic_string<CharT> symbol()
@@ -169,63 +164,52 @@
       }
     };
 
-
     template <class CharT, class Rep, class Period>
- std::basic_string<CharT> duration_unit(std::locale const &loc, bool is_prefix, duration<Rep,Period> const& d) {
- if (is_prefix) {
- return translate(loc,
- ratio_string_id<Period>(),
- duration_unit_strings<Period, CharT>::singular(),
- duration_unit_strings<Period, CharT>::plural(),
- d.count()
- );
+ std::basic_string<CharT> duration_unit(std::locale const &loc, bool is_prefix, duration<Rep, Period> const& d)
+ {
+ if (is_prefix)
+ {
+ return translate(loc, ratio_string_id<Period> (), duration_unit_strings<Period, CharT>::singular(),
+ duration_unit_strings<Period, CharT>::plural(), d.count());
       }
       else
       {
- return translate(loc,
- ratio_string_id<Period>(),
- duration_unit_strings<Period, CharT>::symbol()
- );
+ return translate(loc, ratio_string_id<Period> (), duration_unit_strings<Period, CharT>::symbol());
       }
     }
 
     template <class CharT, class Rep, class Period>
- std::basic_string<CharT> translated_duration_unit(std::locale const &loc, bool is_prefix, duration<Rep,Period> const& d) {
- if (is_prefix) {
- return translate(loc,
- ratio_string_id<Period>(),
- value<CharT>::name()+duration_unit_strings<Period, CharT>::singular(),
- value<CharT>::name()+duration_unit_strings<Period, CharT>::plural(),
- d.count()
- );
+ std::basic_string<CharT> translated_duration_unit(std::locale const &loc, bool is_prefix,
+ duration<Rep, Period> const& d)
+ {
+ if (is_prefix)
+ {
+ return translate(loc, ratio_string_id<Period> (),
+ value<CharT>::name() + duration_unit_strings<Period, CharT>::singular(),
+ value<CharT>::name() + duration_unit_strings<Period, CharT>::plural(), d.count());
       }
       else
       {
- return translate(loc,
- ratio_string_id<Period>(),
- value<CharT>::name()+duration_unit_strings<Period, CharT>::symbol()
- );
+ return translate(loc, ratio_string_id<Period> (),
+ value<CharT>::name() + duration_unit_strings<Period, CharT>::symbol());
       }
     }
 
     template <class CharT, class Period>
- std::basic_string<CharT> translated_duration_unit(std::locale const &loc, bool is_prefix) {
- if (is_prefix) {
- return translate(loc,
- ratio_string_id<Period>(),
- value<CharT>::name()+period<CharT>::name()+duration_unit_strings<Period, CharT>::plural()
- );
+ std::basic_string<CharT> translated_duration_unit(std::locale const &loc, bool is_prefix)
+ {
+ if (is_prefix)
+ {
+ return translate(loc, ratio_string_id<Period> (),
+ value<CharT>::name() + period<CharT>::name() + duration_unit_strings<Period, CharT>::plural());
       }
       else
       {
- return translate(loc,
- ratio_string_id<Period>(),
- value<CharT>::name()+period<CharT>::name()+duration_unit_strings<Period, CharT>::symbol()
- );
+ return translate(loc, ratio_string_id<Period> (),
+ value<CharT>::name() + period<CharT>::name() + duration_unit_strings<Period, CharT>::symbol());
       }
     }
 
-
   } // chrono
 
 }

Added: trunk/boost/chrono/io/ios_base_state.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/chrono/io/ios_base_state.hpp 2011-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
@@ -0,0 +1,174 @@
+// boost/chrono/io/detail/fmt_masks.hpp
+//
+// (C) Copyright 2010-2011 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 to Boost
+
+#ifndef BOOST_CHRONO_IO_IOS_BASE_STATE_HPP
+#define BOOST_CHRONO_IO_IOS_BASE_STATE_HPP
+
+#include <boost/chrono/config.hpp>
+#include <locale>
+#include <boost/chrono/io/duration_style.hpp>
+#include <boost/chrono/io/timezone.hpp>
+
+namespace boost
+{
+ namespace chrono
+ {
+ namespace detail
+ {
+
+ enum chrono_fmt_masks
+ {
+ duration_style_mask = 1 << 0, timezone_mask = 1 << 1, registerd_callback_mask = 1 << 2
+ };
+ inline int chrono_io_masks_index()
+ {
+ static const int v_ = std::ios_base::xalloc();
+ return v_;
+ }
+ inline bool is_registerd(std::ios_base & ios)
+ {
+ long iw = ios.iword(chrono_io_masks_index());
+ return (iw & registerd_callback_mask);
+ }
+ inline void set_registered(std::ios_base& ios)
+ {
+ long& iw = ios.iword(chrono_io_masks_index());
+ iw |= registerd_callback_mask;
+ }
+ }// detail
+
+ inline duration_style::type get_duration_style(std::ios_base & ios)
+ {
+ long iw = ios.iword(detail::chrono_io_masks_index());
+ return (iw & detail::duration_style_mask) ? duration_style::symbol : duration_style::prefix;
+ }
+ inline void set_duration_style(std::ios_base& ios, duration_style::type style)
+ {
+ long& iw = ios.iword(detail::chrono_io_masks_index());
+ iw &= ~detail::duration_style_mask;
+ iw |= (style ? detail::duration_style_mask : 0);
+ }
+
+ inline timezone_type get_timezone(std::ios_base & ios)
+ {
+ long iw = ios.iword(detail::chrono_io_masks_index());
+ return (iw & detail::timezone_mask) ? timezone::local : timezone::utc;
+ }
+ inline void set_timezone(std::ios_base& ios, timezone_type style)
+ {
+ long& iw = ios.iword(detail::chrono_io_masks_index());
+ iw &= ~detail::timezone_mask;
+ iw |= (style ? detail::timezone_mask : 0);
+ }
+
+ namespace detail
+ {
+
+ template<typename CharT>
+ class time_info
+ {
+ public:
+
+ time_info(std::basic_string<CharT> fmt) :
+ fmt_(fmt)
+ {
+ }
+
+ static inline std::basic_string<CharT> get_time_fmt(std::ios_base & ios)
+ {
+ register_once(index(), ios);
+ void* &pw = ios.pword(index());
+ if (pw == 0)
+ {
+ return "";
+ }
+ return static_cast<const time_info<CharT>*> (pw)->fmt_;
+ }
+ static inline void set_time_fmt(std::ios_base& ios, std::basic_string<
+ CharT> fmt)
+ {
+
+ register_once(index(), ios);
+ void*& pw = ios.pword(index());
+ if (pw != 0)
+ {
+ delete static_cast<time_info<CharT>*> (pw);
+ }
+ pw = new time_info(fmt);
+
+ }
+ private:
+ static inline void callback(std::ios_base::event evt, std::ios_base& ios, int index)
+ {
+ switch (evt)
+ {
+ case std::ios_base::erase_event:
+ {
+ void*& pw = ios.pword(index);
+ if (pw != 0)
+ {
+ time_info* tmi = static_cast<time_info<CharT>*> (pw);
+ delete tmi;
+ pw = 0;
+ }
+ break;
+ }
+ case std::ios_base::copyfmt_event:
+ {
+ void*& pw = ios.pword(index);
+ if (pw != 0)
+ {
+ pw = new time_info(static_cast<time_info<CharT>*> (pw)->fmt_);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ static inline void register_once(int index, std::ios_base& ios)
+ {
+ if (!detail::is_registerd(ios))
+ {
+ detail::set_registered(ios);
+ ios.register_callback(callback, index);
+ }
+ }
+
+ static inline int index()
+ {
+ static const int v_ = std::ios_base::xalloc();
+ return v_;
+ }
+
+ std::basic_string<CharT> fmt_;
+
+ };
+
+ } // detail
+
+ template<typename CharT>
+ static inline std::basic_string<CharT> get_time_fmt(std::ios_base & ios)
+ {
+ return detail::time_info<CharT>::get_time_fmt(ios);
+ }
+ template<typename CharT>
+ static inline void set_time_fmt(std::ios_base& ios, std::basic_string<
+ CharT> fmt)
+ {
+
+ detail::time_info<CharT>::set_time_fmt(ios, fmt);
+
+ }
+ } // chrono
+} // boost
+
+#endif // header

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-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
@@ -19,6 +19,7 @@
 #include <boost/chrono/round.hpp>
 #include <boost/chrono/io/translate.hpp>
 #include <boost/chrono/clock_string.hpp>
+#include <boost/chrono/io/ios_base_state.hpp>
 #include <cstring>
 #include <string.h>
 
@@ -28,113 +29,8 @@
   namespace chrono
   {
 
- struct timezone
- {
- enum type
- {
- utc, local
- };
- };
-
- typedef timezone::type timezone_type;
- namespace detail
- {
 
- inline timezone_type get_timezone(std::ios_base & ios)
- {
- long iw = ios.iword(chrono_io_masks_index());
- return (iw & timezone_mask) ? timezone::local : timezone::utc;
- }
- inline void set_timezone(std::ios_base& ios, timezone_type style)
- {
- long& iw = ios.iword(chrono_io_masks_index());
- iw &= ~timezone_mask;
- iw |= (style ? timezone_mask : 0);
- }
-
- template<typename CharT>
- class time_info
- {
- public:
 
- time_info(std::basic_string<CharT> fmt) :
- fmt_(fmt)
- {
- }
-
- static inline std::basic_string<CharT> get_time_fmt(std::ios_base & ios)
- {
- register_once(index(), ios);
- void* &pw = ios.pword(index());
- if (pw == 0)
- {
- return "";
- }
- return static_cast<const time_info<CharT>*> (pw)->fmt_;
- }
- static inline void set_time_fmt(std::ios_base& ios, std::basic_string<
- CharT> fmt)
- {
-
- register_once(index(), ios);
- void*& pw = ios.pword(index());
- if (pw != 0)
- {
- delete static_cast<time_info<CharT>*> (pw);
- }
- pw = new time_info(fmt);
-
- }
- private:
- static inline void callback(std::ios_base::event evt, std::ios_base& ios, int index)
- {
- switch (evt)
- {
- case std::ios_base::erase_event:
- {
- void*& pw = ios.pword(index);
- if (pw != 0)
- {
- time_info* tmi = static_cast<time_info<CharT>*> (pw);
- delete tmi;
- pw = 0;
- }
- break;
- }
- case std::ios_base::copyfmt_event:
- {
- void*& pw = ios.pword(index);
- if (pw != 0)
- {
- pw = new time_info(static_cast<time_info<CharT>*> (pw)->fmt_);
- }
- break;
- }
- default:
- break;
- }
- }
-
- static inline void register_once(int index, std::ios_base& ios)
- {
- if (!detail::is_registerd(ios))
- {
- detail::set_registered(ios);
- ios.register_callback(callback, index);
- }
- }
-
- static inline int index()
- {
- static const int v_ = std::ios_base::xalloc();
- return v_;
- }
-
- std::basic_string<CharT> fmt_;
-
- };
-
- }
 #if ! defined BOOST_CHRONO_IO_USE_XALLOC
 
     template<class CharT>
@@ -201,8 +97,8 @@
 #if ! defined BOOST_CHRONO_IO_USE_XALLOC
         os.imbue(std::locale(os.getloc(), new time_punct<CharT> (m.tz_, m.fmt_)));
 #else
- detail::time_info<CharT>::set_time_fmt(os, m.fmt_);
- detail::set_timezone(os, m.tz_);
+ set_time_fmt<CharT>(os, m.fmt_);
+ set_timezone(os, m.tz_);
 #endif
         return os;
       }
@@ -215,8 +111,8 @@
 #if ! defined BOOST_CHRONO_IO_USE_XALLOC
         is.imbue(std::locale(is.getloc(), new time_punct<CharT> (m.tz_, m.fmt_)));
 #else
- detail::time_info<CharT>::set_time_fmt(is, m.fmt_);
- detail::set_timezone(is, m.tz_);
+ set_time_fmt<CharT>(is, m.fmt_);
+ set_timezone(is, m.tz_);
 #endif
         return is;
       }
@@ -244,8 +140,8 @@
         os.imbue(std::locale(os.getloc(), new time_punct<CharT> (static_cast<timezone_type> (m), std::basic_string<
                     CharT>())));
 #else
- detail::time_info<CharT>::set_time_fmt(os, "");
- detail::set_timezone(os, static_cast<timezone_type> (m));
+ set_time_fmt<CharT>(os, "");
+ set_timezone(os, static_cast<timezone_type> (m));
 #endif
         return os;
       }
@@ -258,8 +154,8 @@
         is.imbue(std::locale(is.getloc(), new time_punct<CharT> (static_cast<timezone_type> (m), std::basic_string<
                     CharT>())));
 #else
- detail::time_info<CharT>::set_time_fmt(is, "");
- detail::set_timezone(is, static_cast<timezone_type> (m));
+ set_time_fmt<CharT>(is, "");
+ set_timezone(is, static_cast<timezone_type> (m));
 #endif
         return is;
       }
@@ -543,11 +439,11 @@
           const CharT* pb = 0; //nullptr;
           const CharT* pe = pb;
           std::basic_string<CharT> fmt =
- detail::time_info<CharT>::get_time_fmt(os);
+ get_time_fmt<CharT>(os);
           pb = fmt.data();
           pe = pb + fmt.size();
 
- timezone_type tz = detail::get_timezone(os);
+ timezone_type tz = get_timezone(os);
           std::locale loc = os.getloc();
 #endif
           time_t t = system_clock::to_time_t(tp);
@@ -717,11 +613,11 @@
           const CharT* pb = 0; //nullptr;
           const CharT* pe = pb;
           std::basic_string<CharT> fmt =
- detail::time_info<CharT>::get_time_fmt(is);
+ get_time_fmt<CharT>(is);
           pb = fmt.data();
           pe = pb + fmt.size();
 
- timezone_type tz = detail::get_timezone(is);
+ timezone_type tz = get_timezone(is);
           std::locale loc = is.getloc();
 #endif
           const std::time_get<CharT>& tg =

Added: trunk/boost/chrono/io/timezone.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/chrono/io/timezone.hpp 2011-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
@@ -0,0 +1,36 @@
+// chrono_io
+//
+// (C) Copyright Howard Hinnant
+// (C) Copyright 2010-2011 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 to Boost
+
+#ifndef BOOST_CHRONO_IO_TIMEZONE_HPP
+#define BOOST_CHRONO_IO_TIMEZONE_HPP
+#include <iostream>
+
+namespace boost
+{
+ namespace chrono
+ {
+ /**
+ * Scoped enumeration emulation stating whether the time_point for system_clock I/O is UTC or local.
+ */
+ struct timezone
+ {
+ enum type
+ {
+ utc, local
+ };
+ };
+
+ typedef timezone::type timezone_type;
+
+ } // chrono
+} // boost
+
+#endif // header

Modified: trunk/boost/chrono/io/translate.hpp
==============================================================================
--- trunk/boost/chrono/io/translate.hpp (original)
+++ trunk/boost/chrono/io/translate.hpp 2011-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
@@ -16,13 +16,15 @@
   namespace chrono
   {
 
-
 #if !defined BOOST_CHRONO_SPECIFIC_TRANSLATE
     template <class CharT, class Rep>
- std::basic_string<CharT> duration_prefix_translate(std::basic_string<CharT> const &singular, std::basic_string<CharT> const &plural, Rep v)
+ std::basic_string<CharT> duration_prefix_translate(std::basic_string<CharT> const &singular,
+ std::basic_string<CharT> const &plural, Rep v)
     {
- if ( v == 1 ) return singular;
- if ( v == -1 ) return singular;
+ if (v == 1)
+ return singular;
+ if (v == -1)
+ return singular;
       return plural;
     }
 
@@ -38,23 +40,24 @@
       return epoch;
     }
     template <class CharT>
- std::basic_string<CharT> translate(std::locale const &, int , std::basic_string<CharT> const &dfault)
+ std::basic_string<CharT> translate(std::locale const &, int, std::basic_string<CharT> const &dfault)
     {
       return dfault;
     }
 
     template <class CharT>
- std::basic_string<CharT> translate(std::locale const &, int , std::basic_string<CharT> const &singular, std::basic_string<CharT> const &plural, int v)
+ std::basic_string<CharT> translate(std::locale const &, int, std::basic_string<CharT> const &singular,
+ std::basic_string<CharT> const &plural, int v)
     {
- if ( v == 1 ) return singular;
- if ( v == -1 ) return singular;
+ if (v == 1)
+ return singular;
+ if (v == -1)
+ return singular;
       return plural;
     }
 
 #endif
 
-
-
   } // chrono
 
 }

Modified: trunk/boost/chrono/io/unit_strings.hpp
==============================================================================
--- trunk/boost/chrono/io/unit_strings.hpp (original)
+++ trunk/boost/chrono/io/unit_strings.hpp 2011-10-31 07:43:23 EDT (Mon, 31 Oct 2011)
@@ -12,6 +12,7 @@
 #include <boost/chrono/duration.hpp>
 #include <boost/chrono/io/duration_style.hpp>
 #include <boost/chrono/process_cpu_clocks.hpp>
+#include <boost/chrono/io/ios_base_state.hpp>
 #include <string>
 #include <iostream>
 //#include <locale>
@@ -21,687 +22,847 @@
 {
   namespace chrono
   {
+ template <typename Period>
+ struct is_localizable: false_type
+ {
+ };
 
- namespace detail
+ template <>
+ struct is_localizable<atto> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<femto> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<pico> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<nano> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<micro> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<milli> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<centi> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<deci> : true_type
     {
+ };
+ template <>
+ struct is_localizable<ratio<1> > : true_type
+ {
+ };
+ template <>
+ struct is_localizable<deca> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<hecto> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<kilo> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<mega> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<tera> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<peta> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<exa> : true_type
+ {
+ };
+ template <>
+ struct is_localizable<ratio<60> > : true_type
+ {
+ };
+ template <>
+ struct is_localizable<ratio<3600> > : true_type
+ {
+ };
 
- class rt_ratio {
- public:
- template <typename Period>
- rt_ratio(Period const&)
- : num(Period::type::num)
- , den(Period::type::den)
- {}
+ namespace detail
+ {
 
- intmax_t num;
- intmax_t den;
- };
+ class rt_ratio
+ {
+ public:
+ template <typename Period>
+ rt_ratio(Period const&) :
+ num(Period::type::num), den(Period::type::den)
+ {
+ }
+
+ intmax_t num;
+ intmax_t den;
+ };
     }
 
- template <typename CharT>
- class chrono_units: public std::locale::facet
+ /**
+ * @c duration_units facet gives useful information about the duration units,
+ * as the number of plural forms, the plural form associated to a duration,
+ * the text associated to a plural form and a duration's period,
+ */
+ template <typename CharT, class OutputIterator = std::ostreambuf_iterator<CharT> >
+ class duration_units: public std::locale::facet
     {
     public:
+ typedef CharT char_type;
+ typedef OutputIterator iter_type;
+
       static std::locale::id id;
 
- explicit chrono_units(size_t refs = 0) :
+ explicit duration_units(size_t refs = 0) :
         std::locale::facet(refs)
- {}
+ {
+ }
 
- // used for input and ouput
+ /* TBR */
       virtual bool swaps_value_unit_order() const = 0;
 
+ /**
+ *
+ * @tparam Rep
+ * @tparam Period
+ * @Requires Rep must be explicitly convertible to int_least64_t.
+ * @Requires Period is named.
+ *
+ * @param s
+ * @param ios
+ * @param d
+ * @Effects puts the unit associated to the duration @c d in @c s taken in account the @c ios state flags.
+ * The implementation uses the non template virtual function do_put as if
+ * @code
+ * return do_put(s, ios, get_duration_style(ios), Period(), int_least64_t(d.count()));
+ * @codeend
+ *
+ * where @get_duration_style gives the duration style associated to @ios.
+ * @return s
+ */
+ template <typename Rep, typename Period>
+ typename enable_if<is_localizable<Period> , iter_type>::type put(iter_type s, std::ios_base& ios,
+ duration<Rep, Period> const& d) const
+ {
+ return do_put(s, ios, get_duration_style(ios), Period(), int_least64_t(d.count()));
+ }
+
+ /**
+ *
+ * @tparam Rep
+ * @tparam Period
+ * @Requires Rep must be explicitly convertible to int_least64_t.
+ * @Requires Period is not named, that is its textual representation is in the form [N/D].
+ *
+ * @param s
+ * @param ios
+ * @param d
+ * @Effects puts the unit associated to the duration @c d in @c s taken in account the @c ios state flags.
+ * The implementation uses the non template virtual function do_put as if
+ * @code
+ * return do_put(s, ios, get_duration_style(ios), detail::rt_ratio(Period()), int_least64_t(d.count()));
+ * @codeend
+ *
+ * where @get_duration_style gives the duration style associated to @ios and
+ * detail::rt_ratio is a class that flats the template ration on a run-time ration so we can use it in virtual functions.
+ * @return s
+ */
+ template <typename Rep, typename Period>
+ typename disable_if<is_localizable<Period> , iter_type>::type put(iter_type s, std::ios_base& ios,
+ duration<Rep, Period> const& d) const
+ {
+ return do_put(s, ios, get_duration_style(ios), detail::rt_ratio(Period()), int_least64_t(d.count()));
+ }
+
+ /**
+ *
+ * @return the number of plural forms.
+ */
+ std::size_t get_plural_forms() const
+ {
+ return do_get_plural_forms();
+ }
+
+ /**
+ *
+ * @param value
+ * @return the associated plural form index.
+ */
+ std::size_t plural_form(int_least64_t value) const
+ {
+ return do_get_plural_form(value);
+ }
+
+ /**
+ *
+ * @param style
+ * @param pf
+ * @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(
+ duration_style::type style, std::size_t pf) const
+ {
+ return do_get_plural_form(style, Period(), pf);
+ }
+
+ /**
+ *
+ * @return the pattern to be used by default.
+ */
+ std::basic_string<CharT> get_pattern() const
+ {
+ return do_get_pattern();
+ }
+
+ protected:
+ virtual std::basic_string<CharT> 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;
+
       // used for ouput
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, atto, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, pico, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, nano, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, micro, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, milli, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, centi, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, deci, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, ratio<1>, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, deca, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, hecto, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, kilo, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, mega, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, tera, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, peta, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, exa, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, detail::rt_ratio, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, ratio<60>, int_least64_t) const = 0;
- virtual std::basic_string<CharT>
- to_string(duration_style::type style, ratio<3600>, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, atto, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, pico, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, nano, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, micro, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, milli, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, centi, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, deci, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, ratio<1> , int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, deca, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, hecto, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, kilo, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, mega, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, tera, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, peta, int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, exa, int_least64_t) const = 0;
+ virtual iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, detail::rt_ratio,
+ int_least64_t) const = 0;
+ virtual iter_type
+ do_put(iter_type s, std::ios_base& ios, duration_style::type style, ratio<60> , int_least64_t) const = 0;
+ virtual iter_type
+ 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::size_t plural_forms() const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, atto, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, pico, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, nano, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, micro, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, milli, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, centi, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, deci, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> plural_form(duration_style::type style, ratio<1>, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, deca, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, hecto, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, kilo, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, mega, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, giga, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, tera, std::size_t pf) const = 0;
-// virtual std::basic_string<CharT> plural_form(duration_style::type style, exa, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> plural_form(duration_style::type style, ratio<60>, std::size_t pf) const = 0;
- virtual std::basic_string<CharT> plural_form(duration_style::type style, ratio<3600>, std::size_t pf) const = 0;
-
- virtual std::size_t plural_form(int_least64_t value) const = 0;
+ // 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, 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, 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;
 
     };
 
- template<class CharT>
- std::locale::id chrono_units<CharT>::id;
+ template <typename CharT, class OutputIterator>
+ std::locale::id duration_units<CharT, OutputIterator>::id;
 
     ///////////////////////////
     // This class is used to define the strings for the default English
- template <typename CharT>
- class chrono_units_default : public chrono_units<CharT>
+ template <typename CharT, class OutputIterator = std::ostreambuf_iterator<CharT> >
+ class duration_units_default: public duration_units<CharT, OutputIterator>
     {
     public:
+ typedef CharT char_type;
+ typedef OutputIterator iter_type;
 
- explicit chrono_units_default(size_t refs = 0) :
- chrono_units<CharT>(refs)
- {}
-
+ explicit duration_units_default(size_t refs = 0) :
+ duration_units<CharT> (refs)
+ {
+ }
       bool swaps_value_unit_order() const
- { return false; }
+ {
+ return false;
+ }
 
- std::basic_string<CharT> to_string(duration_style::type style, atto, int_least64_t value) const
+ protected:
+ std::size_t do_get_plural_forms() const
       {
- return to_string(style, atto())+to_string(style, ratio<1>(), value);
+ return 2;
       }
- std::basic_string<CharT> to_string(duration_style::type style, pico, int_least64_t value) const
+
+ std::size_t do_get_plural_form(int_least64_t value) const
       {
- return to_string(style, pico())+to_string(style, ratio<1>(), value);
+ return (value == -1 || value == 1) ? 0 : 1;
       }
 
- std::basic_string<CharT> to_string(duration_style::type style, nano, int_least64_t value) const
+ std::basic_string<CharT> do_get_pattern() const
       {
- return to_string(style, nano())+to_string(style, ratio<1>(), value);
+ static const CharT t[] =
+ { '%', 'v', ' ', '%', 'u' };
+ static const std::basic_string<CharT> pattern(t, t + sizeof (t) / sizeof (t[0]));
+
+ return pattern;
       }
- std::basic_string<CharT> to_string(duration_style::type style, micro, int_least64_t value) const
+
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, atto u, int_least64_t value) const
       {
- return to_string(style, micro())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
- std::basic_string<CharT> to_string(duration_style::type style, milli, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, pico u, int_least64_t value) const
       {
- return to_string(style, milli())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
- std::basic_string<CharT> to_string(duration_style::type style, centi, int_least64_t value) const
+
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, nano u, int_least64_t value) const
       {
- return to_string(style, centi())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
- std::basic_string<CharT> to_string(duration_style::type style, deci, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, micro u, int_least64_t value) const
       {
- return to_string(style, deci())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
- std::basic_string<CharT> to_string(duration_style::type style, ratio<1> u, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, milli u, int_least64_t value) const
       {
- return plural_form(style, u, plural_form(value));
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
- std::basic_string<CharT> to_string(duration_style::type style, deca, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, centi u, int_least64_t value) const
       {
- return to_string(style, deca())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
- std::basic_string<CharT> to_string(duration_style::type style, hecto, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, deci u, int_least64_t value) const
       {
- return to_string(style, hecto())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
-
- std::basic_string<CharT> to_string(duration_style::type style, kilo, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base&, duration_style::type style, ratio<1> u, int_least64_t value) const
       {
- return to_string(style, kilo())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_plural_form(style, u, do_get_plural_form(value));
+ return std::copy(str.begin(), str.end(), s);
       }
- std::basic_string<CharT> to_string(duration_style::type style, mega, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, deca u, int_least64_t value) const
       {
- return to_string(style, mega())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
- std::basic_string<CharT> to_string(duration_style::type style, giga, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, hecto u, int_least64_t value) const
       {
- return to_string(style, giga())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
- std::basic_string<CharT> to_string(duration_style::type style, tera, int_least64_t value) const
+
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, kilo u, int_least64_t value) const
       {
- return to_string(style, tera())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
- std::basic_string<CharT> to_string(duration_style::type style, peta, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, mega u, int_least64_t value) const
       {
- return to_string(style, peta())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
- std::basic_string<CharT> to_string(duration_style::type style, exa, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, giga u, int_least64_t value) const
       {
- return to_string(style, exa())+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
-
- std::basic_string<CharT> to_string(duration_style::type style, ratio<60> u, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, tera u, int_least64_t value) const
       {
- return plural_form(style, u, plural_form(value));
+ std::basic_string<CharT> str = do_get_ratio_prefix(style, u);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
-
- std::basic_string<CharT> to_string(duration_style::type style, ratio<3600> u, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, peta u, int_least64_t value) const
       {
- return plural_form(style, u, plural_form(value));
+ std::basic_string<CharT> 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);
+ std::copy(str.begin(), str.end(), s);
+ return do_put(s, ios, style, ratio<1> (), value);
       }
 
- std::basic_string<CharT> to_string(duration_style::type style, detail::rt_ratio rtr, int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base&, duration_style::type style, ratio<60> u, int_least64_t value) const
       {
- std::basic_ostringstream<CharT> os;
- os << CharT('[') << rtr.num << CharT('/')
- << rtr.den << CharT(']');
- return os.str()+to_string(style, ratio<1>(), value);
+ std::basic_string<CharT> str = do_get_plural_form(style, u, do_get_plural_form(value));
+ return std::copy(str.begin(), str.end(), s);
       }
- std::size_t plural_forms() const
+
+ iter_type do_put(iter_type s, std::ios_base&, duration_style::type style, ratio<3600> u, int_least64_t value) const
       {
- return 2;
+ std::basic_string<CharT> str = do_get_plural_form(style, u, do_get_plural_form(value));
+ return std::copy(str.begin(), str.end(), s);
       }
 
- std::size_t plural_form(int_least64_t value) const
+ iter_type do_put(iter_type s, std::ios_base& ios, duration_style::type style, detail::rt_ratio rtr,
+ int_least64_t value) const
       {
- return (value==-1 || value==1) ? 0 : 1;
+ *s++ = CharT('[');
+ std::use_facet<std::num_put<CharT, iter_type> >(ios.getloc()).put(s, ios, ' ', rtr.num);
+ *s++ = CharT('/');
+ std::use_facet<std::num_put<CharT, iter_type> >(ios.getloc()).put(s, ios, ' ', rtr.den);
+ *s++ = CharT(']');
+
+ return do_put(s, ios, style, ratio<1> (), value);
       }
 
- std::basic_string<CharT> plural_form(duration_style::type style, ratio<1>, std::size_t pf) const
+ std::basic_string<CharT> 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 std::basic_string<CharT> 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 std::basic_string<CharT> 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 std::basic_string<CharT> 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> plural_form(duration_style::type style, ratio<60>, std::size_t pf) const
+ std::basic_string<CharT> 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 std::basic_string<CharT> 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 std::basic_string<CharT> 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 std::basic_string<CharT> 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> plural_form(duration_style::type style, ratio<3600>, std::size_t pf) const
+ std::basic_string<CharT> 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 CharT u[] =
+ static const std::basic_string<CharT> 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 std::basic_string<CharT> 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 std::basic_string<CharT> 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> plural_form(duration_style::type style, duration<boost::int_least64_t, atto>, std::size_t pf) const
-// {
-// return to_string(style, atto())+plural_form(style, ratio<1>(), pf);
-// }
-// std::basic_string<CharT> plural_form(duration_style::type style, duration<boost::int_least64_t, pico>, std::size_t pf) const
-// {
-// return to_string(style, pico())+plural_form(style, ratio<1>(), pf);
-// }
-// std::basic_string<CharT> plural_form(duration_style::type style, duration<boost::int_least64_t, nano>, std::size_t pf) const
-// {
-// return to_string(style, nano())+plural_form(style, ratio<1>(), pf);
-// }
-// std::basic_string<CharT> plural_form(duration_style::type style, duration<boost::int_least64_t, micro>, std::size_t pf) const
-// {
-// return to_string(style, micro())+plural_form(style, ratio<1>(), pf);
-// }
-// std::basic_string<CharT> plural_form(duration_style::type style, duration<boost::int_least64_t, milli>, std::size_t pf) const
-// {
-// return to_string(style, milli())+plural_form(style, ratio<1>(), pf);
-// }
-// std::basic_string<CharT> plural_form(duration_style::type style, duration<boost::int_least64_t, centi>, std::size_t pf) const
-// {
-// return to_string(style, centi())+plural_form(style, ratio<1>(), pf);
-// }
+ // std::basic_string<CharT> do_get_plural_form(duration_style::type style, duration<boost::int_least64_t, atto>, std::size_t pf) const
+ // {
+ // return to_string(style, atto())+do_get_plural_form(style, ratio<1>(), pf);
+ // }
+ // std::basic_string<CharT> do_get_plural_form(duration_style::type style, duration<boost::int_least64_t, pico>, std::size_t pf) const
+ // {
+ // return to_string(style, pico())+do_get_plural_form(style, ratio<1>(), pf);
+ // }
+ // std::basic_string<CharT> do_get_plural_form(duration_style::type style, duration<boost::int_least64_t, nano>, std::size_t pf) const
+ // {
+ // return to_string(style, nano())+do_get_plural_form(style, ratio<1>(), pf);
+ // }
+ // std::basic_string<CharT> do_get_plural_form(duration_style::type style, duration<boost::int_least64_t, micro>, std::size_t pf) const
+ // {
+ // return to_string(style, micro())+do_get_plural_form(style, ratio<1>(), pf);
+ // }
+ // std::basic_string<CharT> do_get_plural_form(duration_style::type style, duration<boost::int_least64_t, milli>, std::size_t pf) const
+ // {
+ // return to_string(style, milli())+do_get_plural_form(style, ratio<1>(), pf);
+ // }
+ // std::basic_string<CharT> do_get_plural_form(duration_style::type style, duration<boost::int_least64_t, centi>, std::size_t pf) const
+ // {
+ // return to_string(style, centi())+do_get_plural_form(style, ratio<1>(), pf);
+ // }
 
     protected:
 
- virtual std::basic_string<CharT> to_string(duration_style::type style, atto) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, atto) const
       {
         static const CharT u[] =
         { 'a', 't', 't', 'o' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'a' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, pico) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, pico) const
       {
         static const CharT u[] =
         { 'p', 'i', 'c', 'o' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'p' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, nano) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, nano) const
       {
         static const CharT u[] =
         { 'n', 'a', 'n', 'o' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'n' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, micro) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, micro) const
       {
         static const CharT u[] =
         { 'm', 'i', 'c', 'r', 'o' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'u' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
 
- virtual std::basic_string<CharT> to_string(duration_style::type style, milli) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, milli) const
       {
         static const CharT u[] =
         { 'm', 'i', 'l', 'l', 'i' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'm' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, centi) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, centi) const
       {
         static const CharT u[] =
         { 'c', 'e', 'n', 't', 'i' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'c' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, deci) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, deci) const
       {
         static const CharT u[] =
         { 'd', 'e', 'c', 'i' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'd' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, deca) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, deca) const
       {
         static const CharT u[] =
         { 'd', 'e', 'c', 'a' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'd', 'a' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, hecto) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, hecto) const
       {
         static const CharT u[] =
         { 'h', 'e', 'c', 't', 'o' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'h' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, kilo) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, kilo) const
       {
         static const CharT u[] =
         { 'k', 'i', 'l', 'o' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'k' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, mega) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, mega) const
       {
         static const CharT u[] =
         { 'm', 'e', 'g', 'a' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'M' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, giga) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, giga) const
       {
         static const CharT u[] =
         { 'g', 'i', 'g', 'a' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'G' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, tera) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, tera) const
       {
         static const CharT u[] =
         { 't', 'e', 'r', 'a' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'T' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, peta) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, peta) const
       {
         static const CharT u[] =
         { 'p', 'e', 't', 'a' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'P' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
- virtual std::basic_string<CharT> to_string(duration_style::type style, exa) const
+ virtual std::basic_string<CharT> do_get_ratio_prefix(duration_style::type style, exa) const
       {
         static const CharT u[] =
         { 'e', 'x', 'a' };
- static const std::basic_string<CharT> prefix(u, u + sizeof(u)
- / sizeof(u[0]));
+ static const std::basic_string<CharT> prefix(u, u + sizeof (u) / sizeof (u[0]));
         static const CharT v[] =
         { 'E' };
- static const std::basic_string<CharT> symbol(v, v + sizeof(v)
- / sizeof(v[0]));
+ static const std::basic_string<CharT> symbol(v, v + sizeof (v) / sizeof (v[0]));
 
- if (style==duration_style::symbol) return symbol;
+ if (style == duration_style::symbol) return symbol;
         return prefix;
       }
 
     };
 
- template <typename Period>
- struct is_localizable : false_type {};
+#if defined BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL
 
- template <>
- struct is_localizable<atto> : true_type {};
- template <>
- struct is_localizable<femto> : true_type {};
- template <>
- struct is_localizable<pico> : true_type {};
- template <>
- struct is_localizable<nano> : true_type {};
- template <>
- struct is_localizable<micro> : true_type {};
- template <>
- struct is_localizable<milli> : true_type {};
- template <>
- struct is_localizable<centi> : true_type {};
- template <>
- struct is_localizable<deci> : true_type {};
- template <>
- struct is_localizable<ratio<1> > : true_type {};
- template <>
- struct is_localizable<deca> : true_type {};
- template <>
- struct is_localizable<hecto> : true_type {};
- template <>
- struct is_localizable<kilo> : true_type {};
- template <>
- struct is_localizable<mega> : true_type {};
- template <>
- struct is_localizable<tera> : true_type {};
- template <>
- struct is_localizable<peta> : true_type {};
- template <>
- struct is_localizable<exa> : true_type {};
- template <>
- struct is_localizable<ratio<60> > : true_type {};
- template <>
- struct is_localizable<ratio<3600> > : true_type {};
-
-
- template <typename CharT, typename T>
- std::basic_string<CharT> to_basic_string(T const&v, std::locale const &loc)
+ template <typename CharT, typename T>
+ std::basic_string<CharT> to_basic_string(T const&v, std::locale const &loc)
+ {
+ std::basic_ostringstream<CharT> os;
+ os.imbue(loc);
+ os << v;
+ return os.str();
+ }
+
+ template <typename CharT, typename Rep, typename Period>
+ typename enable_if<is_localizable<Period>, std::basic_string<CharT> >::type
+ to_basic_string(
+ duration_style::type style,
+ duration<Rep,Period> value,
+ std::locale const &loc
+ )
+ {
+ std::locale nloc;
+ if (!std::has_facet<duration_units<CharT> >(loc))
     {
- std::basic_ostringstream<CharT> os;
- os.imbue(loc);
- os << v;
- return os.str();
+ nloc =std::locale(loc, new duration_units_default<CharT>());
     }
-
- template <typename CharT, typename Rep, typename Period>
- typename enable_if<is_localizable<Period>, std::basic_string<CharT> >::type
- to_basic_string(
- duration_style::type style,
- duration<Rep,Period> value,
- std::locale const &loc
- )
+ else
     {
- std::locale nloc;
- if (!std::has_facet<chrono_units<CharT> >(loc))
- {
- nloc =std::locale(loc, new chrono_units_default<CharT>());
- }
- else
- {
- nloc=loc;
- }
- chrono_units<CharT> const & f = std::use_facet<chrono_units<CharT> >(nloc);
-
- if (f.swaps_value_unit_order())
- {
- return f.to_string(style, Period(), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
- }
- else
- {
- return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, Period(), int_least64_t(value.count())) ;
- }
+ nloc=loc;
     }
+ duration_units<CharT> const & f = std::use_facet<duration_units<CharT> >(nloc);
 
-
- template <typename CharT, typename Rep, typename Period>
- typename disable_if<is_localizable<Period> , std::basic_string<CharT> >::type
- to_basic_string(
- duration_style::type style,
- duration<Rep,Period> value,
- std::locale const& loc
- )
+ if (f.swaps_value_unit_order())
     {
- std::locale nloc;
- if (!std::has_facet<chrono_units<CharT> >(loc))
- {
- nloc =std::locale(loc, new chrono_units_default<CharT>());
- }
- else
- {
- nloc=loc;
- }
- chrono_units<CharT> const & f = std::use_facet<chrono_units<CharT> >(nloc);
- if (f.swaps_value_unit_order())
- {
- return f.to_string(style, detail::rt_ratio(Period()), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
- }
- else
- {
- return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, detail::rt_ratio(Period()), int_least64_t(value.count()));
- }
+ return f.to_string(style, Period(), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
+ }
+ else
+ {
+ return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, Period(), int_least64_t(value.count()));
     }
+ }
 
- template <typename CharT, typename Rep, typename Period>
- typename enable_if<is_localizable<Period>, std::basic_string<CharT> >::type
- to_basic_string(
- duration_style::type style,
- duration<process_times<Rep>,Period> value,
- std::locale const &loc
- )
+ template <typename CharT, typename Rep, typename Period>
+ typename disable_if<is_localizable<Period> , std::basic_string<CharT> >::type
+ to_basic_string(
+ duration_style::type style,
+ duration<Rep,Period> value,
+ std::locale const& loc
+ )
+ {
+ std::locale nloc;
+ if (!std::has_facet<duration_units<CharT> >(loc))
     {
- std::locale nloc;
- if (!std::has_facet<chrono_units<CharT> >(loc))
- {
- nloc =std::locale(loc, new chrono_units_default<CharT>());
- }
- else
- {
- nloc=loc;
- }
- chrono_units<CharT> const & f = std::use_facet<chrono_units<CharT> >(nloc);
+ nloc =std::locale(loc, new duration_units_default<CharT>());
+ }
+ else
+ {
+ nloc=loc;
+ }
+ duration_units<CharT> const & f = std::use_facet<duration_units<CharT> >(nloc);
+ if (f.swaps_value_unit_order())
+ {
+ return f.to_string(style, detail::rt_ratio(Period()), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
+ }
+ else
+ {
+ return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, detail::rt_ratio(Period()), int_least64_t(value.count()));
+ }
+ }
 
- if (f.swaps_value_unit_order())
- {
- return f.to_string(style, nano(), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
- }
- else
- {
- return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, nano(), int_least64_t(value.count())) ;
- }
+ template <typename CharT, typename Rep, typename Period>
+ typename enable_if<is_localizable<Period>, std::basic_string<CharT> >::type
+ to_basic_string(
+ duration_style::type style,
+ duration<process_times<Rep>,Period> value,
+ std::locale const &loc
+ )
+ {
+ std::locale nloc;
+ if (!std::has_facet<duration_units<CharT> >(loc))
+ {
+ nloc =std::locale(loc, new duration_units_default<CharT>());
+ }
+ else
+ {
+ nloc=loc;
     }
+ duration_units<CharT> const & f = std::use_facet<duration_units<CharT> >(nloc);
 
- template <typename CharT, typename Rep, typename Period>
- typename disable_if<is_localizable<Period> , std::basic_string<CharT> >::type
- to_basic_string(
- duration_style::type style,
- duration<process_times<Rep>,Period> value,
- std::locale const& loc
- )
+ if (f.swaps_value_unit_order())
     {
- std::locale nloc;
- if (!std::has_facet<chrono_units<CharT> >(loc))
- {
- nloc =std::locale(loc, new chrono_units_default<CharT>());
- }
- else
- {
- nloc=loc;
- }
- chrono_units<CharT> const & f = std::use_facet<chrono_units<CharT> >(nloc);
- if (f.swaps_value_unit_order())
- {
- return f.to_string(style, detail::rt_ratio(nano()), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
- }
- else
- {
- return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, detail::rt_ratio(nano()), int_least64_t(value.count()));
- }
+ return f.to_string(style, nano(), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
+ }
+ else
+ {
+ return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, nano(), int_least64_t(value.count()));
     }
+ }
 
- template <typename CharT, typename Rep, typename Period>
- std::basic_string<CharT>
- to_basic_string(duration_style::type style, duration<Rep,Period> value)
+ template <typename CharT, typename Rep, typename Period>
+ typename disable_if<is_localizable<Period> , std::basic_string<CharT> >::type
+ to_basic_string(
+ duration_style::type style,
+ duration<process_times<Rep>,Period> value,
+ std::locale const& loc
+ )
+ {
+ std::locale nloc;
+ if (!std::has_facet<duration_units<CharT> >(loc))
+ {
+ nloc =std::locale(loc, new duration_units_default<CharT>());
+ }
+ else
+ {
+ nloc=loc;
+ }
+ duration_units<CharT> const & f = std::use_facet<duration_units<CharT> >(nloc);
+ if (f.swaps_value_unit_order())
     {
- return to_basic_string<CharT>(style, value, std::locale());
+ return f.to_string(style, detail::rt_ratio(nano()), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
     }
+ else
+ {
+ return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, detail::rt_ratio(nano()), int_least64_t(value.count()));
+ }
+ }
 
+ template <typename CharT, typename Rep, typename Period>
+ std::basic_string<CharT>
+ to_basic_string(duration_style::type style, duration<Rep,Period> value)
+ {
+ return to_basic_string<CharT>(style, value, std::locale());
+ }
+#endif
 
   } // chrono
 


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