[cfe-commits] [libcxx] r160184 - in /libcxx/trunk: include/ test/utilities/time/ test/utilities/time/time.duration/time.duration.arithmetic/ test/utilities/time/time.duration/time.duration.cast/ test/utilities/time/time.duration/time.duration.comparisons/ test/utilities/time/time.duration/time.duration.cons/ test/utilities/time/time.duration/time.duration.nonmember/ test/utilities/time/time.duration/time.duration.special/ test/utilities/time/time.traits/time.traits.duration_values/
Howard Hinnant
hhinnant at apple.com
Fri Jul 13 12:17:27 PDT 2012
Author: hhinnant
Date: Fri Jul 13 14:17:27 2012
New Revision: 160184
URL: http://llvm.org/viewvc/llvm-project?rev=160184&view=rev
Log:
Applied constexpr to <chrono>.
Modified:
libcxx/trunk/include/chrono
libcxx/trunk/test/utilities/time/rep.h
libcxx/trunk/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.special/max.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.special/min.pass.cpp
libcxx/trunk/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp
libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp
libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp
libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp
Modified: libcxx/trunk/include/chrono
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/chrono?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/include/chrono (original)
+++ libcxx/trunk/include/chrono Fri Jul 13 14:17:27 2012
@@ -20,6 +20,7 @@
{
template <class ToDuration, class Rep, class Period>
+constexpr
ToDuration
duration_cast(const duration<Rep, Period>& fd);
@@ -29,9 +30,9 @@
struct duration_values
{
public:
- static Rep zero();
- static Rep max();
- static Rep min();
+ static constexpr Rep zero();
+ static constexpr Rep max();
+ static constexpr Rep min();
};
// duration
@@ -46,9 +47,9 @@
typedef Rep rep;
typedef Period period;
- duration() = default;
+ constexpr duration() = default;
template <class Rep2>
- explicit duration(const Rep2& r,
+ constexpr explicit duration(const Rep2& r,
typename enable_if
<
is_convertible<Rep2, rep>::value &&
@@ -58,7 +59,7 @@
// conversions
template <class Rep2, class Period2>
- duration(const duration<Rep2, Period2>& d,
+ constexpr duration(const duration<Rep2, Period2>& d,
typename enable_if
<
treat_as_floating_point<rep>::value ||
@@ -67,12 +68,12 @@
// observer
- rep count() const;
+ constexpr rep count() const;
// arithmetic
- duration operator+() const;
- duration operator-() const;
+ constexpr duration operator+() const;
+ constexpr duration operator-() const;
duration& operator++();
duration operator++(int);
duration& operator--();
@@ -86,9 +87,9 @@
// special values
- static duration zero();
- static duration min();
- static duration max();
+ static constexpr duration zero();
+ static constexpr duration min();
+ static constexpr duration max();
};
typedef duration<long long, nano> nanoseconds;
@@ -145,36 +146,48 @@
// duration arithmetic
template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period, class Rep2>
+ constexpr
duration<typename common_type<Rep1, Rep2>::type, Period>
operator*(const duration<Rep1, Period>& d, const Rep2& s);
template <class Rep1, class Period, class Rep2>
+ constexpr
duration<typename common_type<Rep1, Rep2>::type, Period>
operator*(const Rep1& s, const duration<Rep2, Period>& d);
template <class Rep1, class Period, class Rep2>
+ constexpr
duration<typename common_type<Rep1, Rep2>::type, Period>
operator/(const duration<Rep1, Period>& d, const Rep2& s);
template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
typename common_type<Rep1, Rep2>::type
operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
// duration comparisons
template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
+ constexpr
bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
// duration_cast
@@ -306,7 +319,7 @@
template <class _FromDuration, class _ToDuration, class _Period>
struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true>
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
_ToDuration operator()(const _FromDuration& __fd) const
{
return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));
@@ -316,7 +329,7 @@
template <class _FromDuration, class _ToDuration, class _Period>
struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false>
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
_ToDuration operator()(const _FromDuration& __fd) const
{
typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
@@ -328,7 +341,7 @@
template <class _FromDuration, class _ToDuration, class _Period>
struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true>
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
_ToDuration operator()(const _FromDuration& __fd) const
{
typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
@@ -340,7 +353,7 @@
template <class _FromDuration, class _ToDuration, class _Period>
struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false>
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
_ToDuration operator()(const _FromDuration& __fd) const
{
typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
@@ -352,6 +365,7 @@
template <class _ToDuration, class _Rep, class _Period>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
typename enable_if
<
__is_duration<_ToDuration>::value,
@@ -369,9 +383,9 @@
struct _LIBCPP_VISIBLE duration_values
{
public:
- _LIBCPP_INLINE_VISIBILITY static _Rep zero() {return _Rep(0);}
- _LIBCPP_INLINE_VISIBILITY static _Rep max() {return numeric_limits<_Rep>::max();}
- _LIBCPP_INLINE_VISIBILITY static _Rep min() {return numeric_limits<_Rep>::lowest();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() {return _Rep(0);}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max() {return numeric_limits<_Rep>::max();}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() {return numeric_limits<_Rep>::lowest();}
};
// duration
@@ -389,9 +403,9 @@
rep __rep_;
public:
- _LIBCPP_INLINE_VISIBILITY duration() {} // = default;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration() {} // = default;
template <class _Rep2>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
explicit duration(const _Rep2& __r,
typename enable_if
<
@@ -403,7 +417,7 @@
// conversions
template <class _Rep2, class _Period2>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
duration(const duration<_Rep2, _Period2>& __d,
typename enable_if
<
@@ -415,12 +429,12 @@
// observer
- _LIBCPP_INLINE_VISIBILITY rep count() const {return __rep_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;}
// arithmetic
- _LIBCPP_INLINE_VISIBILITY duration operator+() const {return *this;}
- _LIBCPP_INLINE_VISIBILITY duration operator-() const {return duration(-__rep_);}
+ _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;}
@@ -436,9 +450,9 @@
// special values
- _LIBCPP_INLINE_VISIBILITY static duration zero() {return duration(duration_values<rep>::zero());}
- _LIBCPP_INLINE_VISIBILITY static duration min() {return duration(duration_values<rep>::min());}
- _LIBCPP_INLINE_VISIBILITY static duration max() {return duration(duration_values<rep>::max());}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() {return duration(duration_values<rep>::zero());}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min() {return duration(duration_values<rep>::min());}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max() {return duration(duration_values<rep>::max());}
};
typedef duration<long long, nano> nanoseconds;
@@ -453,7 +467,7 @@
template <class _LhsDuration, class _RhsDuration>
struct __duration_eq
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs)
{
typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
@@ -464,13 +478,14 @@
template <class _LhsDuration>
struct __duration_eq<_LhsDuration, _LhsDuration>
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs)
{return __lhs.count() == __rhs.count();}
};
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
bool
operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
@@ -481,6 +496,7 @@
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
bool
operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
@@ -492,7 +508,7 @@
template <class _LhsDuration, class _RhsDuration>
struct __duration_lt
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs)
{
typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
@@ -503,13 +519,14 @@
template <class _LhsDuration>
struct __duration_lt<_LhsDuration, _LhsDuration>
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs)
{return __lhs.count() < __rhs.count();}
};
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
bool
operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
@@ -520,6 +537,7 @@
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
bool
operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
@@ -530,6 +548,7 @@
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
bool
operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
@@ -540,6 +559,7 @@
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
bool
operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
@@ -550,30 +570,31 @@
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_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 __r = __lhs;
- __r += __rhs;
- return __r;
+ typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
+ return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());
}
// Duration -
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_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 __r = __lhs;
- __r -= __rhs;
- return __r;
+ typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
+ return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());
}
// Duration *
template <class _Rep1, class _Period, class _Rep2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
typename enable_if
<
is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
@@ -582,13 +603,13 @@
operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef typename common_type<_Rep1, _Rep2>::type _Cr;
- duration<_Cr, _Period> __r = __d;
- __r *= static_cast<_Cr>(__s);
- return __r;
+ typedef duration<_Cr, _Period> _Cd;
+ return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s));
}
template <class _Rep1, class _Period, class _Rep2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
typename enable_if
<
is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value,
@@ -627,17 +648,18 @@
template <class _Rep1, class _Period, class _Rep2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
typename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef typename common_type<_Rep1, _Rep2>::type _Cr;
- duration<_Cr, _Period> __r = __d;
- __r /= static_cast<_Cr>(__s);
- return __r;
+ typedef duration<_Cr, _Period> _Cd;
+ return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s));
}
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
typename common_type<_Rep1, _Rep2>::type
operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
@@ -649,23 +671,24 @@
template <class _Rep1, class _Period, class _Rep2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
typename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef typename common_type<_Rep1, _Rep2>::type _Cr;
- duration<_Cr, _Period> __r = __d;
- __r %= static_cast<_Cr>(__s);
- return __r;
+ typedef duration<_Cr, _Period> _Cd;
+ return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s));
}
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_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 __r = __lhs;
- __r %= __rhs;
- return __r;
+ typedef typename common_type<_Rep1, _Rep2>::type _Cr;
+ typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
+ return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count()));
}
//////////////////////////////////////////////////////////
@@ -710,8 +733,8 @@
// special values
- _LIBCPP_INLINE_VISIBILITY static time_point min() {return time_point(duration::min());}
- _LIBCPP_INLINE_VISIBILITY static time_point max() {return time_point(duration::max());}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() {return time_point(duration::min());}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() {return time_point(duration::max());}
};
} // chrono
Modified: libcxx/trunk/test/utilities/time/rep.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/rep.h?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/rep.h (original)
+++ libcxx/trunk/test/utilities/time/rep.h Fri Jul 13 14:17:27 2012
@@ -5,11 +5,11 @@
{
int data_;
public:
- Rep() : data_(-1) {}
- explicit Rep(int i) : data_(i) {}
+ _LIBCPP_CONSTEXPR Rep() : data_(-1) {}
+ explicit _LIBCPP_CONSTEXPR Rep(int i) : data_(i) {}
- bool operator==(int i) const {return data_ == i;}
- bool operator==(const Rep& r) const {return data_ == r.data_;}
+ bool _LIBCPP_CONSTEXPR operator==(int i) const {return data_ == i;}
+ bool _LIBCPP_CONSTEXPR operator==(const Rep& r) const {return data_ == r.data_;}
Rep& operator*=(Rep x) {data_ *= x.data_; return *this;}
Rep& operator/=(Rep x) {data_ /= x.data_; return *this;}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.arithmetic/op_%2B.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp Fri Jul 13 14:17:27 2012
@@ -18,7 +18,16 @@
int main()
{
+ {
const std::chrono::minutes m(3);
std::chrono::minutes m2 = +m;
assert(m.count() == m2.count());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::minutes m(3);
+ constexpr std::chrono::minutes m2 = +m;
+ static_assert(m.count() == m2.count(), "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp Fri Jul 13 14:17:27 2012
@@ -18,7 +18,16 @@
int main()
{
+ {
const std::chrono::minutes m(3);
std::chrono::minutes m2 = -m;
assert(m2.count() == -m.count());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::minutes m(3);
+ constexpr std::chrono::minutes m2 = -m;
+ static_assert(m2.count() == -m.count(), "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp Fri Jul 13 14:17:27 2012
@@ -12,6 +12,7 @@
// duration
// template <class ToDuration, class Rep, class Period>
+// constexpr
// ToDuration
// duration_cast(const duration<Rep, Period>& d);
@@ -23,9 +24,11 @@
void
test(const FromDuration& f, const ToDuration& d)
{
+ {
typedef decltype(std::chrono::duration_cast<ToDuration>(f)) R;
static_assert((std::is_same<R, ToDuration>::value), "");
assert(std::chrono::duration_cast<ToDuration>(f) == d);
+ }
}
int main()
@@ -40,4 +43,10 @@
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));
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::hours h = std::chrono::duration_cast<std::chrono::hours>(std::chrono::milliseconds(7265000));
+ static_assert(h.count() == 2, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp Fri Jul 13 14:17:27 2012
@@ -12,10 +12,12 @@
// duration
// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
// bool
// operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
// bool
// operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
@@ -66,4 +68,48 @@
assert(s1 == s2);
assert(!(s1 != s2));
}
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(3);
+ static_assert(s1 == s2, "");
+ static_assert(!(s1 != s2), "");
+ }
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(4);
+ static_assert(!(s1 == s2), "");
+ static_assert(s1 != s2, "");
+ }
+ {
+ constexpr std::chrono::milliseconds s1(3);
+ constexpr std::chrono::microseconds s2(3000);
+ static_assert(s1 == s2, "");
+ static_assert(!(s1 != s2), "");
+ }
+ {
+ constexpr std::chrono::milliseconds s1(3);
+ constexpr std::chrono::microseconds s2(4000);
+ static_assert(!(s1 == s2), "");
+ static_assert(s1 != s2, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(10);
+ static_assert(s1 == s2, "");
+ static_assert(!(s1 != s2), "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(10);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(9);
+ static_assert(!(s1 == s2), "");
+ static_assert(s1 != s2, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(10);
+ static_assert(s1 == s2, "");
+ static_assert(!(s1 != s2), "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp Fri Jul 13 14:17:27 2012
@@ -12,18 +12,22 @@
// duration
// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
// bool
// operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
// bool
// operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
// bool
// operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
// bool
// operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
@@ -88,4 +92,62 @@
assert( (s1 <= s2));
assert( (s1 >= s2));
}
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(3);
+ static_assert(!(s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert( (s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(4);
+ static_assert( (s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert(!(s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::milliseconds s1(3);
+ constexpr std::chrono::microseconds s2(3000);
+ static_assert(!(s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert( (s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::milliseconds s1(3);
+ constexpr std::chrono::microseconds s2(4000);
+ static_assert( (s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert(!(s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(10);
+ static_assert(!(s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert( (s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(10);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(9);
+ static_assert(!(s1 < s2), "");
+ static_assert( (s1 > s2), "");
+ static_assert(!(s1 <= s2), "");
+ static_assert( (s1 >= s2), "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+ constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(10);
+ static_assert(!(s1 < s2), "");
+ static_assert(!(s1 > s2), "");
+ static_assert( (s1 <= s2), "");
+ static_assert( (s1 >= s2), "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp Fri Jul 13 14:17:27 2012
@@ -21,7 +21,16 @@
int main()
{
+ {
std::chrono::milliseconds ms(1);
std::chrono::microseconds us = ms;
assert(us.count() == 1000);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::milliseconds ms(1);
+ constexpr std::chrono::microseconds us = ms;
+ static_assert(us.count() == 1000, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp Fri Jul 13 14:17:27 2012
@@ -21,7 +21,16 @@
int main()
{
+ {
std::chrono::duration<double, std::micro> us(1);
std::chrono::duration<double, std::milli> ms = us;
assert(ms.count() == 1./1000);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::duration<double, std::micro> us(1);
+ constexpr std::chrono::duration<double, std::milli> ms = us;
+ static_assert(ms.count() == 1./1000, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp Fri Jul 13 14:17:27 2012
@@ -21,7 +21,16 @@
int main()
{
+ {
std::chrono::duration<int> i(3);
- std::chrono::duration<int> d = i;
- assert(d.count() == 3);
+ std::chrono::duration<double, std::milli> d = i;
+ assert(d.count() == 3000);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::duration<int> i(3);
+ constexpr std::chrono::duration<double, std::milli> d = i;
+ static_assert(d.count() == 3000, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp Fri Jul 13 14:17:27 2012
@@ -26,6 +26,10 @@
{
D d;
assert(d.count() == typename D::rep());
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ constexpr D d2;
+ static_assert(d2.count() == typename D::rep(), "");
+#endif
}
int main()
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp Fri Jul 13 14:17:27 2012
@@ -25,6 +25,10 @@
{
D d(r);
assert(d.count() == r);
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ constexpr D d2(R(2));
+ static_assert(d2.count() == 2, "");
+#endif
}
int main()
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp Fri Jul 13 14:17:27 2012
@@ -23,4 +23,8 @@
{
std::chrono::duration<double> d(5);
assert(d.count() == 5);
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ constexpr std::chrono::duration<double> d2(5);
+ static_assert(d2.count() == 5, "");
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_%2B.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp Fri Jul 13 14:17:27 2012
@@ -44,4 +44,30 @@
std::chrono::duration<double, std::ratio<1, 15> > r = s1 + s2;
assert(r.count() == 75);
}
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(5);
+ constexpr std::chrono::seconds r = s1 + s2;
+ static_assert(r.count() == 8, "");
+ }
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::microseconds s2(5);
+ constexpr std::chrono::microseconds r = s1 + s2;
+ static_assert(r.count() == 3000005, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+ constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 + s2;
+ static_assert(r.count() == 75, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+ constexpr std::chrono::duration<double, std::ratio<1, 15> > r = s1 + s2;
+ static_assert(r.count() == 75, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp Fri Jul 13 14:17:27 2012
@@ -12,6 +12,7 @@
// duration
// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
// typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
// operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
@@ -44,4 +45,30 @@
std::chrono::duration<double, std::ratio<1, 15> > r = s1 - s2;
assert(r.count() == -15);
}
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::seconds s2(5);
+ constexpr std::chrono::seconds r = s1 - s2;
+ static_assert(r.count() == -2, "");
+ }
+ {
+ constexpr std::chrono::seconds s1(3);
+ constexpr std::chrono::microseconds s2(5);
+ constexpr std::chrono::microseconds r = s1 - s2;
+ static_assert(r.count() == 2999995, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+ constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 - s2;
+ static_assert(r.count() == -15, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+ constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+ constexpr std::chrono::duration<double, std::ratio<1, 15> > r = s1 - s2;
+ static_assert(r.count() == -15, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp Fri Jul 13 14:17:27 2012
@@ -12,6 +12,7 @@
// duration
// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
// typename common_type<Rep1, Rep2>::type
// operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
@@ -40,4 +41,26 @@
std::chrono::duration<double, std::ratio<3, 5> > s2(5);
assert(s1 / s2 == 20./3);
}
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::nanoseconds ns1(15);
+ constexpr std::chrono::nanoseconds ns2(5);
+ static_assert(ns1 / ns2 == 3, "");
+ }
+ {
+ constexpr std::chrono::microseconds us1(15);
+ constexpr std::chrono::nanoseconds ns2(5);
+ static_assert(us1 / ns2 == 3000, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(30);
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+ static_assert(s1 / s2 == 6, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(30);
+ constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+ static_assert(s1 / s2 == 20./3, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp Fri Jul 13 14:17:27 2012
@@ -12,6 +12,7 @@
// duration
// template <class Rep1, class Period, class Rep2>
+// constexpr
// duration<typename common_type<Rep1, Rep2>::type, Period>
// operator/(const duration<Rep1, Period>& d, const Rep2& s);
@@ -20,7 +21,16 @@
int main()
{
+ {
std::chrono::nanoseconds ns(15);
ns = ns / 5;
assert(ns.count() == 3);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::nanoseconds ns(15);
+ constexpr std::chrono::nanoseconds ns2 = ns / 5;
+ static_assert(ns2.count() == 3, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp Fri Jul 13 14:17:27 2012
@@ -12,6 +12,7 @@
// duration
// template <class Rep1, class Period1, class Rep2, class Period2>
+// constexpr
// typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
// operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
@@ -38,4 +39,24 @@
std::chrono::duration<int, std::ratio<1, 15> > r = s1 % s2;
assert(r.count() == 24);
}
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::nanoseconds ns1(15);
+ constexpr std::chrono::nanoseconds ns2(6);
+ constexpr std::chrono::nanoseconds r = ns1 % ns2;
+ static_assert(r.count() == 3, "");
+ }
+ {
+ constexpr std::chrono::microseconds us1(15);
+ constexpr std::chrono::nanoseconds ns2(28);
+ constexpr std::chrono::nanoseconds r = us1 % ns2;
+ static_assert(r.count() == 20, "");
+ }
+ {
+ constexpr std::chrono::duration<int, std::ratio<3, 5> > s1(6);
+ constexpr std::chrono::duration<int, std::ratio<2, 3> > s2(3);
+ constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 % s2;
+ static_assert(r.count() == 24, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp Fri Jul 13 14:17:27 2012
@@ -12,6 +12,7 @@
// duration
// template <class Rep1, class Period, class Rep2>
+// constexpr
// duration<typename common_type<Rep1, Rep2>::type, Period>
// operator%(const duration<Rep1, Period>& d, const Rep2& s)
@@ -20,7 +21,16 @@
int main()
{
+ {
std::chrono::nanoseconds ns(15);
ns = ns % 6;
assert(ns.count() == 3);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::nanoseconds ns(15);
+ constexpr std::chrono::nanoseconds ns2 = ns % 6;
+ static_assert(ns2.count() == 3, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp Fri Jul 13 14:17:27 2012
@@ -12,10 +12,12 @@
// duration
// template <class Rep1, class Period, class Rep2>
+// constexpr
// duration<typename common_type<Rep1, Rep2>::type, Period>
// operator*(const duration<Rep1, Period>& d, const Rep2& s);
// template <class Rep1, class Period, class Rep2>
+// constexpr
// duration<typename common_type<Rep1, Rep2>::type, Period>
// operator*(const Rep1& s, const duration<Rep2, Period>& d);
@@ -24,9 +26,20 @@
int main()
{
+ {
std::chrono::nanoseconds ns(3);
ns = ns * 5;
assert(ns.count() == 15);
ns = 6 * ns;
assert(ns.count() == 90);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ constexpr std::chrono::nanoseconds ns(3);
+ constexpr std::chrono::nanoseconds ns2 = ns * 5;
+ static_assert(ns2.count() == 15, "");
+ constexpr std::chrono::nanoseconds ns3 = 6 * ns;
+ static_assert(ns3.count() == 18, "");
+ }
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.special/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.special/max.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.special/max.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.special/max.pass.cpp Fri Jul 13 14:17:27 2012
@@ -22,9 +22,18 @@
template <class D>
void test()
{
+ {
typedef typename D::rep Rep;
Rep max_rep = std::chrono::duration_values<Rep>::max();
assert(D::max().count() == max_rep);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ typedef typename D::rep Rep;
+ constexpr Rep max_rep = std::chrono::duration_values<Rep>::max();
+ static_assert(D::max().count() == max_rep, "");
+ }
+#endif
}
int main()
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.special/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.special/min.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.special/min.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.special/min.pass.cpp Fri Jul 13 14:17:27 2012
@@ -22,9 +22,18 @@
template <class D>
void test()
{
+ {
typedef typename D::rep Rep;
Rep min_rep = std::chrono::duration_values<Rep>::min();
assert(D::min().count() == min_rep);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ typedef typename D::rep Rep;
+ constexpr Rep min_rep = std::chrono::duration_values<Rep>::min();
+ static_assert(D::min().count() == min_rep, "");
+ }
+#endif
}
int main()
Modified: libcxx/trunk/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp Fri Jul 13 14:17:27 2012
@@ -21,9 +21,18 @@
template <class D>
void test()
{
+ {
typedef typename D::rep Rep;
Rep zero_rep = std::chrono::duration_values<Rep>::zero();
assert(D::zero().count() == zero_rep);
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ typedef typename D::rep Rep;
+ constexpr Rep zero_rep = std::chrono::duration_values<Rep>::zero();
+ static_assert(D::zero().count() == zero_rep, "");
+ }
+#endif
}
int main()
Modified: libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp Fri Jul 13 14:17:27 2012
@@ -25,4 +25,12 @@
std::numeric_limits<double>::max());
assert(std::chrono::duration_values<Rep>::max() ==
std::numeric_limits<Rep>::max());
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ static_assert(std::chrono::duration_values<int>::max() ==
+ std::numeric_limits<int>::max(), "");
+ static_assert(std::chrono::duration_values<double>::max() ==
+ std::numeric_limits<double>::max(), "");
+ static_assert(std::chrono::duration_values<Rep>::max() ==
+ std::numeric_limits<Rep>::max(), "");
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp Fri Jul 13 14:17:27 2012
@@ -25,4 +25,12 @@
std::numeric_limits<double>::lowest());
assert(std::chrono::duration_values<Rep>::min() ==
std::numeric_limits<Rep>::lowest());
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ static_assert(std::chrono::duration_values<int>::min() ==
+ std::numeric_limits<int>::lowest(), "");
+ static_assert(std::chrono::duration_values<double>::min() ==
+ std::numeric_limits<double>::lowest(), "");
+ static_assert(std::chrono::duration_values<Rep>::min() ==
+ std::numeric_limits<Rep>::lowest(), "");
+#endif
}
Modified: libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp?rev=160184&r1=160183&r2=160184&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp (original)
+++ libcxx/trunk/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp Fri Jul 13 14:17:27 2012
@@ -20,4 +20,8 @@
{
assert(std::chrono::duration_values<int>::zero() == 0);
assert(std::chrono::duration_values<Rep>::zero() == 0);
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ static_assert(std::chrono::duration_values<int>::zero() == 0, "");
+ static_assert(std::chrono::duration_values<Rep>::zero() == 0, "");
+#endif
}
More information about the cfe-commits
mailing list