[libcxx] r291028 - Implement P0505: 'Wording for GB 50'
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 4 15:03:25 PST 2017
Author: marshall
Date: Wed Jan 4 17:03:24 2017
New Revision: 291028
URL: http://llvm.org/viewvc/llvm-project?rev=291028&view=rev
Log:
Implement P0505: 'Wording for GB 50'
Modified:
libcxx/trunk/include/chrono
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp
libcxx/trunk/www/cxx1z_status.html
Modified: libcxx/trunk/include/chrono
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/chrono?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/include/chrono (original)
+++ libcxx/trunk/include/chrono Wed Jan 4 17:03:24 2017
@@ -77,13 +77,13 @@ public:
constexpr duration operator+() const;
constexpr duration operator-() const;
- duration& operator++();
- duration operator++(int);
- duration& operator--();
- duration operator--(int);
+ constexpr duration& operator++();
+ constexpr duration operator++(int);
+ constexpr duration& operator--();
+ constexpr duration operator--(int);
- duration& operator+=(const duration& d);
- duration& operator-=(const duration& d);
+ constexpr duration& operator+=(const duration& d);
+ constexpr duration& operator-=(const duration& d);
duration& operator*=(const rep& rhs);
duration& operator/=(const rep& rhs);
@@ -567,18 +567,18 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration operator+() const {return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration operator-() const {return duration(-__rep_);}
- _LIBCPP_INLINE_VISIBILITY duration& operator++() {++__rep_; return *this;}
- _LIBCPP_INLINE_VISIBILITY duration operator++(int) {return duration(__rep_++);}
- _LIBCPP_INLINE_VISIBILITY duration& operator--() {--__rep_; return *this;}
- _LIBCPP_INLINE_VISIBILITY duration operator--(int) {return duration(__rep_--);}
-
- _LIBCPP_INLINE_VISIBILITY duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
- _LIBCPP_INLINE_VISIBILITY duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
-
- _LIBCPP_INLINE_VISIBILITY duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}
- _LIBCPP_INLINE_VISIBILITY duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}
- _LIBCPP_INLINE_VISIBILITY duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}
- _LIBCPP_INLINE_VISIBILITY duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++() {++__rep_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}
// special values
Modified: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_%2B%2B.pass.cpp?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp Wed Jan 4 17:03:24 2017
@@ -11,15 +11,31 @@
// duration
-// duration& operator++();
+// constexpr duration& operator++(); // constexpr in c++17
#include <chrono>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool test_constexpr()
+{
+ std::chrono::hours h(3);
+ return (++h).count() == 4;
+}
+#endif
+
int main()
{
+ {
std::chrono::hours h(3);
std::chrono::hours& href = ++h;
assert(&href == &h);
assert(h.count() == 4);
+ }
+
+#if TEST_STD_VER > 14
+ static_assert(test_constexpr(), "");
+#endif
}
Modified: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_%2B%2Bint.pass.cpp?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp Wed Jan 4 17:03:24 2017
@@ -11,15 +11,32 @@
// duration
-// duration operator++(int);
+// constexpr duration operator++(int); // constexpr in c++17
#include <chrono>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool test_constexpr()
+{
+ std::chrono::hours h1(3);
+ std::chrono::hours h2 = h1++;
+ return h1.count() == 4 && h2.count() == 3;
+}
+#endif
+
int main()
{
- std::chrono::hours h(3);
- std::chrono::hours h2 = h++;
- assert(h.count() == 4);
+ {
+ std::chrono::hours h1(3);
+ std::chrono::hours h2 = h1++;
+ assert(h1.count() == 4);
assert(h2.count() == 3);
+ }
+
+#if TEST_STD_VER > 14
+ static_assert(test_constexpr(), "");
+#endif
}
Modified: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_%2B%3D.pass.cpp?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp Wed Jan 4 17:03:24 2017
@@ -11,16 +11,35 @@
// duration
-// duration& operator+=(const duration& d);
+// constexpr duration& operator+=(const duration& d); // constexpr in c++17
#include <chrono>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool test_constexpr()
+{
+ std::chrono::seconds s(3);
+ s += std::chrono::seconds(2);
+ if (s.count() != 5) return false;
+ s += std::chrono::minutes(2);
+ return s.count() == 125;
+}
+#endif
+
int main()
{
+ {
std::chrono::seconds s(3);
s += std::chrono::seconds(2);
assert(s.count() == 5);
s += std::chrono::minutes(2);
assert(s.count() == 125);
+ }
+
+#if TEST_STD_VER > 14
+ static_assert(test_constexpr(), "");
+#endif
}
Modified: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp Wed Jan 4 17:03:24 2017
@@ -11,15 +11,31 @@
// duration
-// duration& operator--();
+// constexpr duration& operator--(); // constexpr in C++17
#include <chrono>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool test_constexpr()
+{
+ std::chrono::hours h(3);
+ return (--h).count() == 2;
+}
+#endif
+
int main()
{
+ {
std::chrono::hours h(3);
std::chrono::hours& href = --h;
assert(&href == &h);
assert(h.count() == 2);
+ }
+
+#if TEST_STD_VER > 14
+ static_assert(test_constexpr(), "");
+#endif
}
Modified: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp Wed Jan 4 17:03:24 2017
@@ -11,15 +11,33 @@
// duration
-// duration operator--(int);
+// constexpr duration operator--(int); // constexpr in C++17
#include <chrono>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool test_constexpr()
+{
+ std::chrono::hours h1(3);
+ std::chrono::hours h2 = h1--;
+ return h1.count() == 2 && h2.count() == 3;
+}
+#endif
+
+
int main()
{
- std::chrono::hours h(3);
- std::chrono::hours h2 = h--;
- assert(h.count() == 2);
+ {
+ std::chrono::hours h1(3);
+ std::chrono::hours h2 = h1--;
+ assert(h1.count() == 2);
assert(h2.count() == 3);
+ }
+
+#if TEST_STD_VER > 14
+ static_assert(test_constexpr(), "");
+#endif
}
Modified: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-%3D.pass.cpp?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp Wed Jan 4 17:03:24 2017
@@ -16,11 +16,30 @@
#include <chrono>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool test_constexpr()
+{
+ std::chrono::seconds s(3);
+ s -= std::chrono::seconds(2);
+ if (s.count() != 1) return false;
+ s -= std::chrono::minutes(2);
+ return s.count() == -119;
+}
+#endif
+
int main()
{
+ {
std::chrono::seconds s(3);
s -= std::chrono::seconds(2);
assert(s.count() == 1);
s -= std::chrono::minutes(2);
assert(s.count() == -119);
+ }
+
+#if TEST_STD_VER > 14
+ static_assert(test_constexpr(), "");
+#endif
}
Modified: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide%3D.pass.cpp?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp Wed Jan 4 17:03:24 2017
@@ -16,9 +16,26 @@
#include <chrono>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool test_constexpr()
+{
+ std::chrono::seconds s(15);
+ s /= 5;
+ return s.count() == 3;
+}
+#endif
+
int main()
{
+ {
std::chrono::nanoseconds ns(15);
ns /= 5;
assert(ns.count() == 3);
+ }
+
+#if TEST_STD_VER > 14
+ static_assert(test_constexpr(), "");
+#endif
}
Modified: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod%3Dduration.pass.cpp?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp Wed Jan 4 17:03:24 2017
@@ -16,12 +16,30 @@
#include <chrono>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool test_constexpr()
+{
+ std::chrono::microseconds us1(11);
+ std::chrono::microseconds us2(3);
+ us1 %= us2;
+ return us1.count() == 2;
+}
+#endif
+
int main()
{
- std::chrono::microseconds us(11);
+ {
+ std::chrono::microseconds us1(11);
std::chrono::microseconds us2(3);
- us %= us2;
- assert(us.count() == 2);
- us %= std::chrono::milliseconds(3);
- assert(us.count() == 2);
+ us1 %= us2;
+ assert(us1.count() == 2);
+ us1 %= std::chrono::milliseconds(3);
+ assert(us1.count() == 2);
+ }
+
+#if TEST_STD_VER > 14
+ static_assert(test_constexpr(), "");
+#endif
}
Modified: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod%3Drep.pass.cpp?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp Wed Jan 4 17:03:24 2017
@@ -16,9 +16,26 @@
#include <chrono>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool test_constexpr()
+{
+ std::chrono::seconds s(11);
+ s %= 3;
+ return s.count() == 2;
+}
+#endif
+
int main()
{
+ {
std::chrono::microseconds us(11);
us %= 3;
assert(us.count() == 2);
+ }
+
+#if TEST_STD_VER > 14
+ static_assert(test_constexpr(), "");
+#endif
}
Modified: libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times%3D.pass.cpp?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp Wed Jan 4 17:03:24 2017
@@ -16,9 +16,26 @@
#include <chrono>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool test_constexpr()
+{
+ std::chrono::seconds s(3);
+ s *= 5;
+ return s.count() == 15;
+}
+#endif
+
int main()
{
+ {
std::chrono::nanoseconds ns(3);
ns *= 5;
assert(ns.count() == 15);
+ }
+
+#if TEST_STD_VER > 14
+ static_assert(test_constexpr(), "");
+#endif
}
Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Wed Jan 4 17:03:24 2017
@@ -132,7 +132,7 @@
<tr><td><a href="http://wg21.link/P0502R0">P0502R0</a></td><td>LWG</td><td>Throwing out of a parallel algorithm terminates - but how?</td><td>Issaquah</td><td></td><td></td></tr>
<tr><td><a href="http://wg21.link/P0503R0">P0503R0</a></td><td>LWG</td><td>Correcting library usage of "literal type"</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
<tr><td><a href="http://wg21.link/P0504R0">P0504R0</a></td><td>LWG</td><td>Revisiting in-place tag types for any/optional/variant</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
- <tr><td><a href="http://wg21.link/P0505R0">P0505R0</a></td><td>LWG</td><td>Wording for GB 50 - constexpr for chrono</td><td>Issaquah</td><td></td><td></td></tr>
+ <tr><td><a href="http://wg21.link/P0505R0">P0505R0</a></td><td>LWG</td><td>Wording for GB 50 - constexpr for chrono</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
<tr><td><a href="http://wg21.link/P0508R0">P0508R0</a></td><td>LWG</td><td>Wording for GB 58 - structured bindings for node_handles</td><td>Issaquah</td><td></td><td></td></tr>
<tr><td><a href="http://wg21.link/P0509R1">P0509R1</a></td><td>LWG</td><td>Updating âRestrictions on exception handlingâ</td><td>Issaquah</td><td><i>Nothing to do</i></td><td>n/a</td></tr>
<tr><td><a href="http://wg21.link/P0510R0">P0510R0</a></td><td>LWG</td><td>Disallowing references, incomplete types, arrays, and empty variants</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
More information about the cfe-commits
mailing list