[libcxx] r187517 - Implement n3469 - constexpr for chrono

Marshall Clow mclow.lists at gmail.com
Wed Jul 31 12:32:19 PDT 2013


Author: marshall
Date: Wed Jul 31 14:32:19 2013
New Revision: 187517

URL: http://llvm.org/viewvc/llvm-project?rev=187517&view=rev
Log:
Implement n3469 - constexpr for chrono

Modified:
    libcxx/trunk/include/chrono
    libcxx/trunk/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
    libcxx/trunk/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp
    libcxx/trunk/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp
    libcxx/trunk/test/utilities/time/time.point/time.point.cons/convert.pass.cpp
    libcxx/trunk/test/utilities/time/time.point/time.point.cons/default.pass.cpp
    libcxx/trunk/test/utilities/time/time.point/time.point.cons/duration.pass.cpp
    libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp
    libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
    libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp

Modified: libcxx/trunk/include/chrono
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/chrono?rev=187517&r1=187516&r2=187517&view=diff
==============================================================================
--- libcxx/trunk/include/chrono (original)
+++ libcxx/trunk/include/chrono Wed Jul 31 14:32:19 2013
@@ -111,16 +111,16 @@ private:
     duration d_;  // exposition only
 
 public:
-    time_point();  // has value "epoch"
-    explicit time_point(const duration& d);  // same as time_point() + d
+    time_point();  // has value "epoch" // constexpr in C++14
+    explicit time_point(const duration& d);  // same as time_point() + d // constexpr in C++14
 
     // conversions
     template <class Duration2>
-       time_point(const time_point<clock, Duration2>& t);
+       time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
 
     // observer
 
-    duration time_since_epoch() const;
+    duration time_since_epoch() const; // constexpr in C++14
 
     // arithmetic
 
@@ -194,7 +194,7 @@ template <class Rep1, class Period1, cla
 template <class ToDuration, class Rep, class Period>
   ToDuration duration_cast(const duration<Rep, Period>& d);
 
-// time_point arithmetic
+// time_point arithmetic (all constexpr in C++14)
 template <class Clock, class Duration1, class Rep2, class Period2>
   time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
   operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
@@ -208,7 +208,7 @@ template <class Clock, class Duration1,
   typename common_type<Duration1, Duration2>::type
   operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
 
-// time_point comparisons
+// time_point comparisons (all constexpr in C++14)
 template <class Clock, class Duration1, class Duration2>
    bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
 template <class Clock, class Duration1, class Duration2>
@@ -222,7 +222,7 @@ template <class Clock, class Duration1,
 template <class Clock, class Duration1, class Duration2>
    bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
 
-// time_point_cast
+// time_point_cast (constexpr in C++14)
 
 template <class ToDuration, class Clock, class Duration>
   time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
@@ -236,7 +236,7 @@ public:
     typedef duration::rep                    rep;
     typedef duration::period                 period;
     typedef chrono::time_point<system_clock> time_point;
-    static const bool is_steady =            false;
+    static const bool is_steady =            false; // constexpr in C++14
 
     static time_point now() noexcept;
     static time_t     to_time_t  (const time_point& __t) noexcept;
@@ -250,7 +250,7 @@ public:
     typedef duration::rep                                 rep;
     typedef duration::period                              period;
     typedef chrono::time_point<steady_clock, duration>    time_point;
-    static const bool is_steady =                         true;
+    static const bool is_steady =                         true; // constexpr in C++14
 
     static time_point now() noexcept;
 };
@@ -416,7 +416,13 @@ private:
     rep __rep_;
 public:
 
-    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration() {} // = default;
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+        duration() {}
+#else
+        duration() = default;
+#endif
+
     template <class _Rep2>
         _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
         explicit duration(const _Rep2& __r,
@@ -722,12 +728,12 @@ private:
     duration __d_;
 
 public:
-    _LIBCPP_INLINE_VISIBILITY time_point() : __d_(duration::zero()) {}
-    _LIBCPP_INLINE_VISIBILITY explicit time_point(const duration& __d) : __d_(__d) {}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {}
 
     // conversions
     template <class _Duration2>
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     time_point(const time_point<clock, _Duration2>& t,
         typename enable_if
         <
@@ -737,7 +743,7 @@ public:
 
     // observer
 
-    _LIBCPP_INLINE_VISIBILITY duration time_since_epoch() const {return __d_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;}
 
     // arithmetic
 
@@ -762,7 +768,7 @@ struct _LIBCPP_TYPE_VIS common_type<chro
 namespace chrono {
 
 template <class _ToDuration, class _Clock, class _Duration>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 time_point<_Clock, _ToDuration>
 time_point_cast(const time_point<_Clock, _Duration>& __t)
 {
@@ -772,7 +778,7 @@ time_point_cast(const time_point<_Clock,
 // time_point ==
 
 template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 bool
 operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
 {
@@ -782,7 +788,7 @@ operator==(const time_point<_Clock, _Dur
 // time_point !=
 
 template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 bool
 operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
 {
@@ -792,7 +798,7 @@ operator!=(const time_point<_Clock, _Dur
 // time_point <
 
 template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 bool
 operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
 {
@@ -802,7 +808,7 @@ operator<(const time_point<_Clock, _Dura
 // time_point >
 
 template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 bool
 operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
 {
@@ -812,7 +818,7 @@ operator>(const time_point<_Clock, _Dura
 // time_point <=
 
 template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 bool
 operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
 {
@@ -822,7 +828,7 @@ operator<=(const time_point<_Clock, _Dur
 // time_point >=
 
 template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 bool
 operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
 {
@@ -832,20 +838,18 @@ operator>=(const time_point<_Clock, _Dur
 // time_point operator+(time_point x, duration y);
 
 template <class _Clock, class _Duration1, class _Rep2, class _Period2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 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> _Tr;
-    _Tr __r(__lhs.time_since_epoch());
-    __r += __rhs;
-    return __r;
+    return _Tr (__lhs.time_since_epoch() + __rhs);
 }
 
 // time_point operator+(duration x, time_point y);
 
 template <class _Rep1, class _Period1, class _Clock, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
 operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
 {
@@ -855,7 +859,7 @@ operator+(const duration<_Rep1, _Period1
 // time_point operator-(time_point x, duration y);
 
 template <class _Clock, class _Duration1, class _Rep2, class _Period2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
 operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
 {
@@ -865,7 +869,7 @@ operator-(const time_point<_Clock, _Dura
 // duration operator-(time_point x, time_point y);
 
 template <class _Clock, class _Duration1, class _Duration2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 typename common_type<_Duration1, _Duration2>::type
 operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
 {
@@ -883,7 +887,7 @@ public:
     typedef duration::rep                    rep;
     typedef duration::period                 period;
     typedef chrono::time_point<system_clock> time_point;
-    static const bool is_steady =            false;
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
 
     static time_point now() _NOEXCEPT;
     static time_t     to_time_t  (const time_point& __t) _NOEXCEPT;
@@ -897,7 +901,7 @@ public:
     typedef duration::rep                                 rep;
     typedef duration::period                              period;
     typedef chrono::time_point<steady_clock, duration>    time_point;
-    static const bool is_steady =                         true;
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true;
 
     static time_point now() _NOEXCEPT;
 };

Modified: libcxx/trunk/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp?rev=187517&r1=187516&r2=187517&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp Wed Jul 31 14:32:19 2013
@@ -26,11 +26,27 @@ test(const FromDuration& df, const ToDur
     typedef std::chrono::system_clock Clock;
     typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
     typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
+    {
     FromTimePoint f(df);
     ToTimePoint t(d);
     typedef decltype(std::chrono::time_point_cast<ToDuration>(f)) R;
     static_assert((std::is_same<R, ToTimePoint>::value), "");
     assert(std::chrono::time_point_cast<ToDuration>(f) == t);
+    }
+}
+
+template<class FromDuration, long long From, class ToDuration, long long To>
+void test_constexpr ()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
+    typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
+    {
+    constexpr FromTimePoint f{FromDuration{From}};
+    constexpr ToTimePoint   t{ToDuration{To}};
+    static_assert(std::chrono::time_point_cast<ToDuration>(f) == t, "");
+    }
+
 }
 
 int main()
@@ -45,4 +61,16 @@ int main()
          std::chrono::duration<double, std::ratio<3600> >(7265./3600));
     test(std::chrono::duration<int, std::ratio<2, 3> >(9),
          std::chrono::duration<int, std::ratio<3, 5> >(10));
+#if _LIBCPP_STD_VER > 11
+    {
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::hours,    2> ();
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::minutes,121> ();
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::seconds,7265> ();
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::milliseconds,7265000> ();
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::microseconds,7265000000LL> ();
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::nanoseconds,7265000000000LL> ();
+    typedef std::chrono::duration<int, std::ratio<3, 5>> T1;
+    test_constexpr<std::chrono::duration<int, std::ratio<2, 3>>, 9, T1, 10> ();
+    }
+#endif
 }

Modified: libcxx/trunk/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp?rev=187517&r1=187516&r2=187517&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp Wed Jul 31 14:32:19 2013
@@ -54,4 +54,31 @@ int main()
     assert(!(t1 == t2));
     assert( (t1 != t2));
     }
+    
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T1 t2(Duration1(3));
+    static_assert( (t1 == t2), "");
+    static_assert(!(t1 != t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T1 t2(Duration1(4));
+    static_assert(!(t1 == t2), "");
+    static_assert( (t1 != t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T2 t2(Duration2(3000));
+    static_assert( (t1 == t2), "");
+    static_assert(!(t1 != t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T2 t2(Duration2(3001));
+    static_assert(!(t1 == t2), "");
+    static_assert( (t1 != t2), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp?rev=187517&r1=187516&r2=187517&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp Wed Jul 31 14:32:19 2013
@@ -70,4 +70,39 @@ int main()
     assert( (t1 <= t2));
     assert(!(t1 >= t2));
     }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T1 t2(Duration1(3));
+    static_assert(!(t1 <  t2), "");
+    static_assert(!(t1 >  t2), "");
+    static_assert( (t1 <= t2), "");
+    static_assert( (t1 >= t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T1 t2(Duration1(4));
+    static_assert( (t1 <  t2), "");
+    static_assert(!(t1 >  t2), "");
+    static_assert( (t1 <= t2), "");
+    static_assert(!(t1 >= t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T2 t2(Duration2(3000));
+    static_assert(!(t1 <  t2), "");
+    static_assert(!(t1 >  t2), "");
+    static_assert( (t1 <= t2), "");
+    static_assert( (t1 >= t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T2 t2(Duration2(3001));
+    static_assert( (t1 <  t2), "");
+    static_assert(!(t1 >  t2), "");
+    static_assert( (t1 <= t2), "");
+    static_assert(!(t1 >= t2), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/utilities/time/time.point/time.point.cons/convert.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.point/time.point.cons/convert.pass.cpp?rev=187517&r1=187516&r2=187517&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.point/time.point.cons/convert.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.point/time.point.cons/convert.pass.cpp Wed Jul 31 14:32:19 2013
@@ -27,4 +27,11 @@ int main()
     std::chrono::time_point<Clock, Duration1> t1 = t2;
     assert(t1.time_since_epoch() == Duration1(3000));
     }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+    constexpr std::chrono::time_point<Clock, Duration1> t1 = t2;
+    static_assert(t1.time_since_epoch() == Duration1(3000), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/utilities/time/time.point/time.point.cons/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.point/time.point.cons/default.pass.cpp?rev=187517&r1=187516&r2=187517&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.point/time.point.cons/default.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.point/time.point.cons/default.pass.cpp Wed Jul 31 14:32:19 2013
@@ -22,6 +22,14 @@ int main()
 {
     typedef std::chrono::system_clock Clock;
     typedef std::chrono::duration<Rep, std::milli> Duration;
+    {
     std::chrono::time_point<Clock, Duration> t;
     assert(t.time_since_epoch() == Duration::zero());
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration> t;
+    static_assert(t.time_since_epoch() == Duration::zero(), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/utilities/time/time.point/time.point.cons/duration.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.point/time.point.cons/duration.pass.cpp?rev=187517&r1=187516&r2=187517&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.point/time.point.cons/duration.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.point/time.point.cons/duration.pass.cpp Wed Jul 31 14:32:19 2013
@@ -28,4 +28,14 @@ int main()
     std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
     assert(t.time_since_epoch() == Duration(3000));
     }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration> t(Duration(3));
+    static_assert(t.time_since_epoch() == Duration(3), "");
+    }
+    {
+    constexpr std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
+    static_assert(t.time_since_epoch() == Duration(3000), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_%2B.pass.cpp?rev=187517&r1=187516&r2=187517&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp Wed Jul 31 14:32:19 2013
@@ -27,9 +27,20 @@ int main()
     typedef std::chrono::system_clock Clock;
     typedef std::chrono::milliseconds Duration1;
     typedef std::chrono::microseconds Duration2;
+    {
     std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
     std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
     assert(t2.time_since_epoch() == Duration2(3005));
     t2 = Duration2(6) + t1;
     assert(t2.time_since_epoch() == Duration2(3006));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
+    static_assert(t2.time_since_epoch() == Duration2(3005), "");
+    constexpr std::chrono::time_point<Clock, Duration2> t3 = Duration2(6) + t1;
+    static_assert(t3.time_since_epoch() == Duration2(3006), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp?rev=187517&r1=187516&r2=187517&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp Wed Jul 31 14:32:19 2013
@@ -23,7 +23,16 @@ int main()
     typedef std::chrono::system_clock Clock;
     typedef std::chrono::milliseconds Duration1;
     typedef std::chrono::microseconds Duration2;
+    {
     std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
     std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
     assert(t2.time_since_epoch() == Duration2(2995));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
+    static_assert(t2.time_since_epoch() == Duration2(2995), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp?rev=187517&r1=187516&r2=187517&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp Wed Jul 31 14:32:19 2013
@@ -23,7 +23,16 @@ int main()
     typedef std::chrono::system_clock Clock;
     typedef std::chrono::milliseconds Duration1;
     typedef std::chrono::microseconds Duration2;
+    {
     std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
     std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
     assert((t1 - t2) == Duration2(2995));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    constexpr std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
+    static_assert((t1 - t2) == Duration2(2995), "");
+    }
+#endif
 }





More information about the cfe-commits mailing list