[libcxx] r252195 - Implement P0092R1 for C++1z
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 5 11:34:00 PST 2015
Author: marshall
Date: Thu Nov 5 13:33:59 2015
New Revision: 252195
URL: http://llvm.org/viewvc/llvm-project?rev=252195&view=rev
Log:
Implement P0092R1 for C++1z
Added:
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp
libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp
libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp
libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp
libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp
libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp
libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp
Modified:
libcxx/trunk/include/chrono
libcxx/trunk/www/cxx1z_status.html
Modified: libcxx/trunk/include/chrono
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/chrono?rev=252195&r1=252194&r2=252195&view=diff
==============================================================================
--- libcxx/trunk/include/chrono (original)
+++ libcxx/trunk/include/chrono Thu Nov 5 13:33:59 2015
@@ -194,6 +194,13 @@ template <class Rep1, class Period1, cla
template <class ToDuration, class Rep, class Period>
ToDuration duration_cast(const duration<Rep, Period>& d);
+template <class ToDuration, class Rep, class Period>
+ constexpr ToDuration floor(const duration<Rep, Period>& d); // C++17
+template <class ToDuration, class Rep, class Period>
+ constexpr ToDuration ceil(const duration<Rep, Period>& d); // C++17
+template <class ToDuration, class Rep, class Period>
+ constexpr ToDuration round(const duration<Rep, Period>& d); // C++17
+
// 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>
@@ -227,6 +234,20 @@ template <class Clock, class Duration1,
template <class ToDuration, class Clock, class Duration>
time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
+template <class ToDuration, class Clock, class Duration>
+ constexpr time_point<Clock, ToDuration>
+ floor(const time_point<Clock, Duration>& tp); // C++17
+
+template <class ToDuration, class Clock, class Duration>
+ constexpr time_point<Clock, ToDuration>
+ ceil(const time_point<Clock, Duration>& tp); // C++17
+
+template <class ToDuration, class Clock, class Duration>
+ constexpr time_point<Clock, ToDuration>
+ round(const time_point<Clock, Duration>& tp); // C++17
+
+template <class Rep, class Period>
+ constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17
// Clocks
class system_clock
@@ -401,6 +422,58 @@ public:
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() {return numeric_limits<_Rep>::lowest();}
};
+#if _LIBCPP_STD_VER > 14
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ _ToDuration
+>::type
+floor(const duration<_Rep, _Period>& __d)
+{
+ _ToDuration __t = duration_cast<_ToDuration>(__d);
+ if (__t > __d)
+ __t = __t - _ToDuration{1};
+ return __t;
+}
+
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ _ToDuration
+>::type
+ceil(const duration<_Rep, _Period>& __d)
+{
+ _ToDuration __t = duration_cast<_ToDuration>(__d);
+ if (__t < __d)
+ __t = __t + _ToDuration{1};
+ return __t;
+}
+
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ _ToDuration
+>::type
+round(const duration<_Rep, _Period>& __d)
+{
+ _ToDuration __lower = floor<_ToDuration>(__d);
+ _ToDuration __upper = __lower + _ToDuration{1};
+ auto __lowerDiff = __d - __lower;
+ auto __upperDiff = __upper - __d;
+ if (__lowerDiff < __upperDiff)
+ return __lower;
+ if (__lowerDiff > __upperDiff)
+ return __upper;
+ return __lower.count() & 1 ? __upper : __lower;
+}
+#endif
+
// duration
template <class _Rep, class _Period>
@@ -807,6 +880,56 @@ time_point_cast(const time_point<_Clock,
return time_point<_Clock, _ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
}
+#if _LIBCPP_STD_VER > 14
+template <class _ToDuration, class _Clock, class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ time_point<_Clock, _ToDuration>
+>::type
+floor(const time_point<_Clock, _Duration>& __t)
+{
+ return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())};
+}
+
+template <class _ToDuration, class _Clock, class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ time_point<_Clock, _ToDuration>
+>::type
+ceil(const time_point<_Clock, _Duration>& __t)
+{
+ return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())};
+}
+
+template <class _ToDuration, class _Clock, class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ __is_duration<_ToDuration>::value,
+ time_point<_Clock, _ToDuration>
+>::type
+round(const time_point<_Clock, _Duration>& __t)
+{
+ return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())};
+}
+
+template <class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ numeric_limits<_Rep>::is_signed,
+ duration<_Rep, _Period>
+>::type
+abs(duration<_Rep, _Period> __d)
+{
+ return __d >= __d.zero() ? __d : -__d;
+}
+#endif
+
// time_point ==
template <class _Clock, class _Duration1, class _Duration2>
Added: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// ceil
+
+// template <class Rep, class Period>
+// constexpr duration<Rep, Period> abs(duration<Rep, Period> d)
+
+// This function shall not participate in overload resolution unless numeric_limits<Rep>::is_signed is true.
+
+#include <chrono>
+
+typedef std::chrono::duration<unsigned> unsigned_secs;
+
+int main()
+{
+ std::chrono::abs(unsigned_secs(0));
+}
Added: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+// <chrono>
+
+// abs
+
+// template <class Rep, class Period>
+// constexpr duration<Rep, Period> abs(duration<Rep, Period> d)
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class Duration>
+void
+test(const Duration& f, const Duration& d)
+{
+ {
+ typedef decltype(std::chrono::abs(f)) R;
+ static_assert((std::is_same<R, Duration>::value), "");
+ assert(std::chrono::abs(f) == d);
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::milliseconds( 7290000));
+ test(std::chrono::milliseconds(-7290000), std::chrono::milliseconds( 7290000));
+ test(std::chrono::minutes( 122), std::chrono::minutes( 122));
+ test(std::chrono::minutes(-122), std::chrono::minutes( 122));
+ test(std::chrono::hours(0), std::chrono::hours(0));
+
+ {
+// 9000000ms is 2 hours and 30 minutes
+ constexpr std::chrono::hours h1 = std::chrono::abs(std::chrono::hours(-3));
+ static_assert(h1.count() == 3, "");
+ constexpr std::chrono::hours h2 = std::chrono::abs(std::chrono::hours(3));
+ static_assert(h2.count() == 3, "");
+ }
+}
Added: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// ceil
+
+// template <class ToDuration, class Rep, class Period>
+// ToDuration
+// ceil(const duration<Rep, Period>& d);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::ceil<int>(std::chrono::milliseconds(3));
+}
Added: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+// <chrono>
+
+// ceil
+
+// template <class ToDuration, class Rep, class Period>
+// constexpr
+// ToDuration
+// ceil(const duration<Rep, Period>& d);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class ToDuration, class FromDuration>
+void
+test(const FromDuration& f, const ToDuration& d)
+{
+ {
+ typedef decltype(std::chrono::ceil<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToDuration>::value), "");
+ assert(std::chrono::ceil<ToDuration>(f) == d);
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 3));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-121));
+
+ {
+// 9000000ms is 2 hours and 30 minutes
+ constexpr std::chrono::hours h1 = std::chrono::ceil<std::chrono::hours>(std::chrono::milliseconds(9000000));
+ static_assert(h1.count() == 3, "");
+ constexpr std::chrono::hours h2 = std::chrono::ceil<std::chrono::hours>(std::chrono::milliseconds(-9000000));
+ static_assert(h2.count() == -2, "");
+ }
+}
Added: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// floor
+
+// template <class ToDuration, class Rep, class Period>
+// ToDuration
+// floor(const duration<Rep, Period>& d);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::floor<int>(std::chrono::milliseconds(3));
+}
Added: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// floor
+
+// template <class ToDuration, class Rep, class Period>
+// constexpr
+// ToDuration
+// floor(const duration<Rep, Period>& d);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class ToDuration, class FromDuration>
+void
+test(const FromDuration& f, const ToDuration& d)
+{
+ {
+ typedef decltype(std::chrono::floor<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToDuration>::value), "");
+ assert(std::chrono::floor<ToDuration>(f) == d);
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-3));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 121));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122));
+
+ {
+// 9000000ms is 2 hours and 30 minutes
+ constexpr std::chrono::hours h1 = std::chrono::floor<std::chrono::hours>(std::chrono::milliseconds(9000000));
+ static_assert(h1.count() == 2, "");
+ constexpr std::chrono::hours h2 = std::chrono::floor<std::chrono::hours>(std::chrono::milliseconds(-9000000));
+ static_assert(h2.count() == -3, "");
+ }
+}
Added: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// round
+
+// template <class ToDuration, class Rep, class Period>
+// ToDuration
+// round(const duration<Rep, Period>& d);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::round<int>(std::chrono::milliseconds(3));
+}
Added: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// round
+
+// template <class ToDuration, class Rep, class Period>
+// constexpr
+// ToDuration
+// ceil(const duration<Rep, Period>& d);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class ToDuration, class FromDuration>
+void
+test(const FromDuration& f, const ToDuration& d)
+{
+ {
+ typedef decltype(std::chrono::round<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToDuration>::value), "");
+ assert(std::chrono::round<ToDuration>(f) == d);
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122));
+
+ {
+// 9000000ms is 2 hours and 30 minutes
+ constexpr std::chrono::hours h1 = std::chrono::round<std::chrono::hours>(std::chrono::milliseconds(9000000));
+ static_assert(h1.count() == 2, "");
+ constexpr std::chrono::hours h2 = std::chrono::round<std::chrono::hours>(std::chrono::milliseconds(-9000000));
+ static_assert(h2.count() == -2, "");
+ }
+}
Added: libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// ceil
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// ceil(const time_point<Clock, Duration>& t);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::ceil<int>(std::chrono::system_clock::now());
+}
Added: libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// ceil
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// ceil(const time_point<Clock, Duration>& t);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class FromDuration, class ToDuration>
+void
+test(const FromDuration& df, const ToDuration& d)
+{
+ 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::ceil<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToTimePoint>::value), "");
+ assert(std::chrono::ceil<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::ceil<ToDuration>(f) == t, "");
+ }
+}
+
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 3));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-121));
+
+// 9000000ms is 2 hours and 30 minutes
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::hours, 3> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::hours, -2> ();
+ test_constexpr<std::chrono::milliseconds, 9000001, std::chrono::minutes, 151> ();
+ test_constexpr<std::chrono::milliseconds,-9000001, std::chrono::minutes,-150> ();
+
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::seconds, 9000> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::seconds,-9000> ();
+}
Added: libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// floor
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// floor(const time_point<Clock, Duration>& t);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::floor<int>(std::chrono::system_clock::now());
+}
Added: libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// floor
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// floor(const time_point<Clock, Duration>& t);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class FromDuration, class ToDuration>
+void
+test(const FromDuration& df, const ToDuration& d)
+{
+ 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::floor<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToTimePoint>::value), "");
+ assert(std::chrono::floor<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::floor<ToDuration>(f) == t, "");
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-3));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 121));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122));
+
+// 9000000ms is 2 hours and 30 minutes
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::hours, 2> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::hours, -3> ();
+ test_constexpr<std::chrono::milliseconds, 9000001, std::chrono::minutes, 150> ();
+ test_constexpr<std::chrono::milliseconds,-9000001, std::chrono::minutes,-151> ();
+
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::seconds, 9000> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::seconds,-9000> ();
+}
Added: libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// round
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// round(const time_point<Clock, Duration>& t);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::round<int>(std::chrono::system_clock::now());
+}
Added: libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp?rev=252195&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp Thu Nov 5 13:33:59 2015
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// round
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// round(const time_point<Clock, Duration>& t);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class FromDuration, class ToDuration>
+void
+test(const FromDuration& df, const ToDuration& d)
+{
+ 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::round<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToTimePoint>::value), "");
+ assert(std::chrono::round<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::round<ToDuration>(f) == t, "");
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122));
+
+// 9000000ms is 2 hours and 30 minutes
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::hours, 2> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::hours, -2> ();
+ test_constexpr<std::chrono::milliseconds, 9000001, std::chrono::minutes, 150> ();
+ test_constexpr<std::chrono::milliseconds,-9000001, std::chrono::minutes,-150> ();
+
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::seconds, 9000> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::seconds,-9000> ();
+}
Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=252195&r1=252194&r2=252195&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Thu Nov 5 13:33:59 2015
@@ -72,7 +72,7 @@
<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0004R1.html">P0004R1</a></td><td>LWG</td><td>Remove Deprecated iostreams aliases.</td><td>Kona</td><td>Complete</td><td>3.8</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0006R0.html">P0006R0</a></td><td>LWG</td><td>Adopt Type Traits Variable Templates for C++17.</td><td>Kona</td><td>In progress</td><td></td></tr>
- <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0092R1.html">P0092R1</a></td><td>LWG</td><td>Polishing <chrono></td><td>Kona</td><td></td><td></td></tr>
+ <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0092R1.html">P0092R1</a></td><td>LWG</td><td>Polishing <chrono></td><td>Kona</td><td>Complete</td><td>3.8</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0007R1.html">P0007R1</a></td><td>LWG</td><td>Constant View: A proposal for a <tt>std::as_const</tt> helper function template.</td><td>Kona</td><td>In progress</td><td></td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0156R0.htm" >P0156R0</a></td><td>LWG</td><td>Variadic lock_guard(rev 3).</td><td>Kona</td><td></td><td></td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0074R0.html">P0074R0</a></td><td>LWG</td><td>Making <tt>std::owner_less</tt> more flexible</td><td>Kona</td><td></td><td></td></tr>
More information about the cfe-commits
mailing list