Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75427 - in trunk/boost/chrono: . detail/no_warning io io_v1
From: vicente.botet_at_[hidden]
Date: 2011-11-09 12:54:18


Author: viboes
Date: 2011-11-09 12:54:17 EST (Wed, 09 Nov 2011)
New Revision: 75427
URL: http://svn.boost.org/trac/boost/changeset/75427

Log:
Chrono: warning removal
Added:
   trunk/boost/chrono/detail/no_warning/
   trunk/boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp (contents, props changed)
Text files modified:
   trunk/boost/chrono/config.hpp | 1 -
   trunk/boost/chrono/io/duration_get.hpp | 6 +++++-
   trunk/boost/chrono/io_v1/chrono_io.hpp | 4 +++-
   3 files changed, 8 insertions(+), 3 deletions(-)

Modified: trunk/boost/chrono/config.hpp
==============================================================================
--- trunk/boost/chrono/config.hpp (original)
+++ trunk/boost/chrono/config.hpp 2011-11-09 12:54:17 EST (Wed, 09 Nov 2011)
@@ -140,7 +140,6 @@
 #endif
 
 //#define BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
-#define BOOST_CHRONO_USES_RATIO_IO
 
 // enable automatic library variant selection ------------------------------//
 

Added: trunk/boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp 2011-11-09 12:54:17 EST (Wed, 09 Nov 2011)
@@ -0,0 +1,44 @@
+// is_evenly_divisible_by.hpp --------------------------------------------------------------//
+
+// Copyright 2009-2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#ifndef BOOST_CHRONO_DETAIL_NO_WARNING_SIGNED_UNSIGNED_CMP_HPP
+#define BOOST_CHRONO_DETAIL_NO_WARNING_SIGNED_UNSIGNED_CMP_HPP
+
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+//../../../boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp:37: warning: comparison between signed and unsigned integer expressions
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
+namespace boost {
+namespace chrono {
+namespace detail {
+
+ template <class T, class U>
+ bool lt(T t, U u)
+ {
+ return t < u;
+ }
+
+ template <class T, class U>
+ bool gt(T t, U u)
+ {
+ return t > u;
+ }
+
+} // namespace detail
+} // namespace detail
+} // namespace chrono
+
+#endif // BOOST_CHRONO_DETAIL_IS_EVENLY_DIVISIBLE_BY_HPP

Modified: trunk/boost/chrono/io/duration_get.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_get.hpp (original)
+++ trunk/boost/chrono/io/duration_get.hpp 2011-11-09 12:54:17 EST (Wed, 09 Nov 2011)
@@ -17,8 +17,11 @@
 #include <boost/mpl/if.hpp>
 #include <boost/math/common_factor_rt.hpp>
 #include <boost/chrono/detail/scan_keyword.hpp>
+#include <boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp>
+
 #include <boost/assert.hpp>
 #include <locale>
+
 /**
  * Duration formatting facet for input.
  */
@@ -284,7 +287,8 @@
         if (!detail::reduce(r, den, err))
           return s;
 
- if (r > ( (duration_values<common_type_t>::max)() / num))
+ //if (r > ( (duration_values<common_type_t>::max)() / num))
+ if (chrono::detail::gt(r,((duration_values<common_type_t>::max)() / num)))
         {
           // Conversion to Period overflowed
           err |= std::ios_base::failbit;

Modified: trunk/boost/chrono/io_v1/chrono_io.hpp
==============================================================================
--- trunk/boost/chrono/io_v1/chrono_io.hpp (original)
+++ trunk/boost/chrono/io_v1/chrono_io.hpp 2011-11-09 12:54:17 EST (Wed, 09 Nov 2011)
@@ -25,6 +25,7 @@
 #include <boost/math/common_factor_rt.hpp>
 #include <boost/chrono/detail/scan_keyword.hpp>
 #include <boost/utility/enable_if.hpp>
+#include <boost/chrono/detail/no_warning/signed_unsigned_cmp.hpp>
 
 namespace boost
 {
@@ -505,7 +506,8 @@
                   return is;
                 }
 
- if (r > ((duration_values<common_type_t>::max)() / num))
+ //if (r > ((duration_values<common_type_t>::max)() / num))
+ if (chrono::detail::gt(r,((duration_values<common_type_t>::max)() / num)))
                 {
                     // Conversion to Period overflowed
                     is.setstate(err|is.failbit);


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