$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r74440 - trunk/boost/chrono
From: vicente.botet_at_[hidden]
Date: 2011-09-17 16:50:55
Author: viboes
Date: 2011-09-17 16:50:54 EDT (Sat, 17 Sep 2011)
New Revision: 74440
URL: http://svn.boost.org/trac/boost/changeset/74440
Log:
Chrono: Take in account the constexpr as defined in the standard #5906 
Text files modified: 
   trunk/boost/chrono/duration.hpp   |    81 ++++++++++++++++++++++++++++++--------- 
   trunk/boost/chrono/time_point.hpp |    25 ++++++++---                             
   2 files changed, 78 insertions(+), 28 deletions(-)
Modified: trunk/boost/chrono/duration.hpp
==============================================================================
--- trunk/boost/chrono/duration.hpp	(original)
+++ trunk/boost/chrono/duration.hpp	2011-09-17 16:50:54 EDT (Sat, 17 Sep 2011)
@@ -448,6 +448,7 @@
                 >::type* = 0
             ) : rep_(r) { }
         ~duration() {} //= default;
+        BOOST_CHRONO_CONSTEXPR
         duration(const duration& rhs) : rep_(rhs.rep_) {} // = default;
         duration& operator=(const duration& rhs) // = default;
         {
@@ -526,35 +527,45 @@
     // Duration +
 
     template <class Rep1, class Period1, class Rep2, class Period2>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
     operator+(const duration<Rep1, Period1>& lhs,
           const duration<Rep2, Period2>& rhs)
     {
-      typename common_type<duration<Rep1, Period1>,
-        duration<Rep2, Period2> >::type result = lhs;
+      typedef typename common_type<duration<Rep1, Period1>,
+        duration<Rep2, Period2> >::type CD;
+#if 0
+      CD result = lhs;
       result += rhs;
       return result;
+#else
+      return CD(CD(lhs).count()+CD(rhs).count());
+#endif
     }
 
     // Duration -
 
     template <class Rep1, class Period1, class Rep2, class Period2>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
     operator-(const duration<Rep1, Period1>& lhs,
           const duration<Rep2, Period2>& rhs)
     {
-        typename common_type<duration<Rep1, Period1>,
-            duration<Rep2, Period2> >::type result = lhs;
-        result -= rhs;
-        return result;
+      typedef typename common_type<duration<Rep1, Period1>,
+            duration<Rep2, Period2> >::type CD;
+#if 0
+      CD result = lhs;
+      result -= rhs;
+      return result;
+#else
+      return CD(CD(lhs).count()-CD(rhs).count());
+#endif
     }
 
     // Duration *
 
     template <class Rep1, class Period, class Rep2>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     typename boost::enable_if <
         mpl::and_ <
         boost::is_convertible<Rep1, typename common_type<Rep1, Rep2>::type>,
@@ -564,14 +575,19 @@
     >::type
     operator*(const duration<Rep1, Period>& d, const Rep2& s)
     {
-        typedef typename common_type<Rep1, Rep2>::type CR;
-            duration<CR, Period> r = d;
+      typedef typename common_type<Rep1, Rep2>::type CR;
+      typedef duration<CR, Period> CD;
+#if 0
+      CD r = d;
         r *= static_cast<CR>(s);
         return r;
+#else
+      return CD(CD(d).count()*static_cast<CR>(s));
+#endif
     }
 
     template <class Rep1, class Period, class Rep2>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     typename boost::enable_if <
         mpl::and_ <
         boost::is_convertible<Rep1, typename common_type<Rep1, Rep2>::type>,
@@ -587,7 +603,7 @@
     // Duration /
 
     template <class Rep1, class Period, class Rep2>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     typename boost::disable_if <boost::chrono::detail::is_duration<Rep2>,
       typename boost::chrono::detail::duration_divide_result<
         duration<Rep1, Period>, Rep2>::type
@@ -595,13 +611,19 @@
     operator/(const duration<Rep1, Period>& d, const Rep2& s)
     {
         typedef typename common_type<Rep1, Rep2>::type CR;
-          duration<CR, Period> r = d;
+        typedef duration<CR, Period> CD;
+
+#if 0
+        CD r = d;
         r /= static_cast<CR>(s);
         return r;
+#else
+      return CD(CD(d).count()/static_cast<CR>(s));
+#endif
     }
 
     template <class Rep1, class Period1, class Rep2, class Period2>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     typename common_type<Rep1, Rep2>::type
     operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
     {
@@ -612,7 +634,7 @@
 
     #ifdef BOOST_CHRONO_EXTENSIONS
     template <class Rep1, class Rep2, class Period>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     typename boost::disable_if <boost::chrono::detail::is_duration<Rep1>,
       typename boost::chrono::detail::duration_divide_result2<
         Rep1, duration<Rep2, Period> >::type
@@ -620,13 +642,20 @@
     operator/(const Rep1& s, const duration<Rep2, Period>& d)
     {
         typedef typename common_type<Rep1, Rep2>::type CR;
-        duration<CR, Period> r = d;
+        typedef duration<CR, Period> CD;
+
+#if 0
+        CD r = d;
         return  static_cast<CR>(s)/r.count();
+#else
+      return static_cast<CR>(s)/CD(d).count();
+#endif
     }
     #endif
     // Duration %
 
     template <class Rep1, class Period, class Rep2>
+    inline BOOST_CHRONO_CONSTEXPR
     typename boost::disable_if <boost::chrono::detail::is_duration<Rep2>,
       typename boost::chrono::detail::duration_modulo_result<
         duration<Rep1, Period>, Rep2>::type
@@ -634,21 +663,33 @@
     operator%(const duration<Rep1, Period>& d, const Rep2& s)
     {
         typedef typename common_type<Rep1, Rep2>::type CR;
-        duration<CR, Period> r = d;
+        typedef duration<CR, Period> CD;
+
+#if 0
+        CD r = d;
         r %= static_cast<CR>(s);
         return r;
-    }
+#else
+      return CD(CD(d).count()%static_cast<CR>(s));
+#endif
+      }
 
     template <class Rep1, class Period1, class Rep2, class Period2>
+    inline BOOST_CHRONO_CONSTEXPR
     typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
     operator%(const duration<Rep1, Period1>& lhs,
           const duration<Rep2, Period2>& rhs) {
         typedef typename common_type<duration<Rep1, Period1>,
                                  duration<Rep2, Period2> >::type CD;
+
+#if 0
         CD r(lhs);
         r%=CD(rhs);
         return r;
-    }
+#else
+      return CD(CD(lhs).count()%CD(rhs).count());
+#endif
+      }
 
 
 //----------------------------------------------------------------------------//
Modified: trunk/boost/chrono/time_point.hpp
==============================================================================
--- trunk/boost/chrono/time_point.hpp	(original)
+++ trunk/boost/chrono/time_point.hpp	2011-09-17 16:50:54 EDT (Sat, 17 Sep 2011)
@@ -78,24 +78,28 @@
 
     // time_point arithmetic
     template <class Clock, class Duration1, class Rep2, class Period2>
+    inline BOOST_CHRONO_CONSTEXPR
     time_point<Clock,
         typename common_type<Duration1, duration<Rep2, Period2> >::type>
     operator+(
             const time_point<Clock, Duration1>& lhs,
             const duration<Rep2, Period2>& rhs);
     template <class Rep1, class Period1, class Clock, class Duration2>
+    inline BOOST_CHRONO_CONSTEXPR
     time_point<Clock,
         typename common_type<duration<Rep1, Period1>, Duration2>::type>
     operator+(
             const duration<Rep1, Period1>& lhs,
             const time_point<Clock, Duration2>& rhs);
     template <class Clock, class Duration1, class Rep2, class Period2>
+    inline BOOST_CHRONO_CONSTEXPR
     time_point<Clock,
         typename common_type<Duration1, duration<Rep2, Period2> >::type>
     operator-(
             const time_point<Clock, Duration1>& lhs,
             const duration<Rep2, Period2>& rhs);
     template <class Clock, class Duration1, class Duration2>
+    inline BOOST_CHRONO_CONSTEXPR
     typename common_type<Duration1, Duration2>::type
     operator-(
             const time_point<Clock, Duration1>& lhs,
@@ -229,25 +233,30 @@
     // time_point operator+(time_point x, duration y);
 
     template <class Clock, class Duration1, class Rep2, class Period2>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     time_point<Clock,
         typename common_type<Duration1, duration<Rep2, Period2> >::type>
     operator+(const time_point<Clock, Duration1>& lhs,
             const duration<Rep2, Period2>& rhs)
     {
-        typedef time_point<
-            Clock,
-            typename common_type<Duration1, duration<Rep2, Period2> >::type
-        > TimeResult;
+      typedef typename common_type<Duration1, duration<Rep2, Period2> >::type CDuration;
+      typedef time_point<
+          Clock,
+          CDuration
+      > TimeResult;
+#if 0
         TimeResult r(lhs);
         r += rhs;
         return r;
+#else
+        return TimeResult(lhs.time_since_epoch() + CDuration(rhs));
+#endif
     }
 
     // time_point operator+(duration x, time_point y);
 
     template <class Rep1, class Period1, class Clock, class Duration2>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     time_point<Clock,
         typename common_type<duration<Rep1, Period1>, Duration2>::type>
     operator+(const duration<Rep1, Period1>& lhs,
@@ -259,7 +268,7 @@
     // time_point operator-(time_point x, duration y);
 
     template <class Clock, class Duration1, class Rep2, class Period2>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     time_point<Clock,
         typename common_type<Duration1, duration<Rep2, Period2> >::type>
     operator-(const time_point<Clock, Duration1>& lhs,
@@ -271,7 +280,7 @@
     // duration operator-(time_point x, time_point y);
 
     template <class Clock, class Duration1, class Duration2>
-    inline
+    inline BOOST_CHRONO_CONSTEXPR
     typename common_type<Duration1, Duration2>::type
     operator-(const time_point<Clock, Duration1>& lhs,
             const time_point<Clock, Duration2>& rhs)