literal suffixes for std::chrono
llvm-svn: 187078
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index c6eef8f..219e20e 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -259,6 +259,19 @@
} // chrono
+constexpr chrono::hours operator "" h(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , ratio<3600,1>> operator "" h(long double); // C++14
+constexpr chrono::minutes operator "" min(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , ratio<60,1>> operator "" min(long double); // C++14
+constexpr chrono::seconds operator "" s(unsigned long long); // C++14
+constexpr chrono::duration<unspecified > operator "" s(long double); // C++14
+constexpr chrono::milliseconds operator "" ms(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , milli> operator "" ms(long double); // C++14
+constexpr chrono::microseconds operator "" us(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , micro> operator "" us(long double); // C++14
+constexpr chrono::nanoseconds operator "" ns(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , nano> operator "" ns(long double); // C++14
+
} // std
*/
@@ -893,6 +906,84 @@
} // chrono
+#if _LIBCPP_STD_VER > 11
+// Literal suffixes for chrono types
+// inline // Deviation from N3690.
+// We believe the inline to be a defect and have submitted an LWG issue.
+// An LWG issue number has not yet been assigned.
+namespace literals
+{
+ inline namespace chrono_literals
+ {
+
+ constexpr chrono::hours operator"" h(unsigned long long __h)
+ {
+ return chrono::hours(static_cast<chrono::hours::rep>(__h));
+ }
+
+ constexpr chrono::duration<long double, ratio<3600,1>> operator"" h(long double __h)
+ {
+ return chrono::duration<long double, ratio<3600,1>>(__h);
+ }
+
+
+ constexpr chrono::minutes operator"" min(unsigned long long __m)
+ {
+ return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
+ }
+
+ constexpr chrono::duration<long double, ratio<60,1>> operator"" min(long double __m)
+ {
+ return chrono::duration<long double, ratio<60,1>> (__m);
+ }
+
+
+ constexpr chrono::seconds operator"" s(unsigned long long __s)
+ {
+ return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
+ }
+
+ constexpr chrono::duration<long double> operator"" s(long double __s)
+ {
+ return chrono::duration<long double> (__s);
+ }
+
+
+ constexpr chrono::milliseconds operator"" ms(unsigned long long __ms)
+ {
+ return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
+ }
+
+ constexpr chrono::duration<long double, milli> operator"" ms(long double __ms)
+ {
+ return chrono::duration<long double, milli>(__ms);
+ }
+
+
+ constexpr chrono::microseconds operator"" us(unsigned long long __us)
+ {
+ return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
+ }
+
+ constexpr chrono::duration<long double, micro> operator"" us(long double __us)
+ {
+ return chrono::duration<long double, micro> (__us);
+ }
+
+
+ constexpr chrono::nanoseconds operator"" ns(unsigned long long __ns)
+ {
+ return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
+ }
+
+ constexpr chrono::duration<long double, nano> operator"" ns(long double __ns)
+ {
+ return chrono::duration<long double, nano> (__ns);
+ }
+
+}}
+#endif
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CHRONO