Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74522 - trunk/boost/chrono/io
From: vicente.botet_at_[hidden]
Date: 2011-09-22 17:15:40


Author: viboes
Date: 2011-09-22 17:15:39 EDT (Thu, 22 Sep 2011)
New Revision: 74522
URL: http://svn.boost.org/trac/boost/changeset/74522

Log:
Chrono: try to make portable timezone::type conversions on PGI
Text files modified:
   trunk/boost/chrono/io/duration_io.hpp | 13 ++++++++-----
   trunk/boost/chrono/io/time_point_io.hpp | 28 ++++++++++++++--------------
   2 files changed, 22 insertions(+), 19 deletions(-)

Modified: trunk/boost/chrono/io/duration_io.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_io.hpp (original)
+++ trunk/boost/chrono/io/duration_io.hpp 2011-09-22 17:15:39 EDT (Thu, 22 Sep 2011)
@@ -643,11 +643,14 @@
             }
             common_type_t t = r * num;
             t /= den;
- if ((duration_values<Rep>::max)() < t)
- {
- // Conversion to Period overflowed
- is.setstate(is.failbit);
- return is;
+ if (t>0) {
+ Rep pt = t;
+ if ((duration_values<Rep>::max)() < pt)
+ {
+ // Conversion to Period overflowed
+ is.setstate(is.failbit);
+ return is;
+ }
             }
             // Success! Store it.
             r = Rep(t);

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-09-22 17:15:39 EDT (Thu, 22 Sep 2011)
@@ -32,6 +32,7 @@
         utc, local
       };
     };
+ typedef timezone::type timezone_type;
 
     template<class CharT>
     class time_punct: public std::locale::facet
@@ -41,7 +42,7 @@
 
     private:
       string_type fmt_;
- chrono::timezone::type tz_;
+ chrono::timezone_type tz_;
 
     public:
       static std::locale::id id;
@@ -51,7 +52,7 @@
       {
       }
 
- time_punct(timezone::type tz, string_type fmt, size_t refs = 0)
+ time_punct(timezone_type tz, string_type fmt, size_t refs = 0)
       // todo use move semantic when available.
       :
         std::locale::facet(refs), fmt_(fmt), tz_(tz)
@@ -62,7 +63,7 @@
       {
         return fmt_;
       }
- chrono::timezone::type get_timezone() const BOOST_CHRONO_NOEXCEPT
+ chrono::timezone_type get_timezone() const BOOST_CHRONO_NOEXCEPT
       {
         return tz_;
       }
@@ -108,14 +109,14 @@
 
       class time_man
       {
- timezone::type form_;
+ timezone_type form_;
       public:
- explicit time_man(timezone::type f) :
+ explicit time_man(timezone_type f) :
           form_(f)
         {
         }
         // explicit
- operator timezone::type() const
+ operator timezone_type() const
         {
           return form_;
         }
@@ -125,7 +126,7 @@
       std::basic_ostream<CharT, Traits>&
       operator <<(std::basic_ostream<CharT, Traits>& os, time_man m)
       {
- os.imbue(std::locale(os.getloc(), new time_punct<CharT> (static_cast<timezone::type> (m), std::basic_string<
+ os.imbue(std::locale(os.getloc(), new time_punct<CharT> (static_cast<timezone_type> (m), std::basic_string<
             CharT>())));
         return os;
       }
@@ -134,14 +135,14 @@
       std::basic_istream<CharT, Traits>&
       operator >>(std::basic_istream<CharT, Traits>& is, time_man m)
       {
- is.imbue(std::locale(is.getloc(), new time_punct<CharT> (static_cast<timezone::type> (m), std::basic_string<
+ is.imbue(std::locale(is.getloc(), new time_punct<CharT> (static_cast<timezone_type> (m), std::basic_string<
             CharT>())));
         return is;
       }
 
     }
 
- inline detail::time_man time_fmt(timezone::type f)
+ inline detail::time_man time_fmt(timezone_type f)
     {
       return detail::time_man(f);
     }
@@ -261,7 +262,7 @@
         {
           const _CharT* pb = 0; //nullptr;
           const _CharT* pe = pb;
- timezone::type tz = timezone::utc;
+ timezone_type tz = timezone::utc;
           typedef time_punct<_CharT> F;
           std::locale loc = os.getloc();
           if (std::has_facet<F>(loc))
@@ -420,20 +421,19 @@
           const _CharT* pe = pb;
           typedef time_punct<_CharT> F;
           std::locale loc = is.getloc();
- timezone::type tz = timezone::utc;
+ timezone_type tz = timezone::utc;
           if (std::has_facet<F>(loc))
           {
             const F& f = std::use_facet<F>(loc);
             pb = f.fmt().data();
             pe = pb + f.fmt().size();
- tz = f.timezone::type();
+ tz = f.timezone_type();
           }
           const std::time_get<_CharT>& tg = std::use_facet<
               std::time_get<_CharT> >(loc);
           const std::ctype<_CharT>& ct =
               std::use_facet<std::ctype<_CharT> >(loc);
- tm tm =
- { 0 };
+ tm tm; // {0}
           typedef std::istreambuf_iterator<_CharT, _Traits> _I;
           if (pb == pe)
           {


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