[libcxx] r187529 - Implement constexpr (n3302) and fix operator *= and /=
Marshall Clow
mclow.lists at gmail.com
Wed Jul 31 14:02:35 PDT 2013
Author: marshall
Date: Wed Jul 31 16:02:34 2013
New Revision: 187529
URL: http://llvm.org/viewvc/llvm-project?rev=187529&view=rev
Log:
Implement constexpr (n3302) and fix operator *= and /=
Modified:
libcxx/trunk/include/complex
libcxx/trunk/test/numerics/complex.number/cmplx.over/imag.pass.cpp
libcxx/trunk/test/numerics/complex.number/cmplx.over/real.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.members/real_imag.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
libcxx/trunk/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
Modified: libcxx/trunk/include/complex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/complex?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/include/complex (original)
+++ libcxx/trunk/include/complex Wed Jul 31 16:02:34 2013
@@ -23,12 +23,12 @@ class complex
public:
typedef T value_type;
- complex(const T& re = T(), const T& im = T());
- complex(const complex&);
- template<class X> complex(const complex<X>&);
+ complex(const T& re = T(), const T& im = T()); // constexpr in C++14
+ complex(const complex&); // constexpr in C++14
+ template<class X> complex(const complex<X>&); // constexpr in C++14
- T real() const;
- T imag() const;
+ T real() const; // constexpr in C++14
+ T imag() const; // constexpr in C++14
void real(T);
void imag(T);
@@ -149,12 +149,12 @@ template<class T> complex<T> operator/(c
template<class T> complex<T> operator/(const T&, const complex<T>&);
template<class T> complex<T> operator+(const complex<T>&);
template<class T> complex<T> operator-(const complex<T>&);
-template<class T> bool operator==(const complex<T>&, const complex<T>&);
-template<class T> bool operator==(const complex<T>&, const T&);
-template<class T> bool operator==(const T&, const complex<T>&);
-template<class T> bool operator!=(const complex<T>&, const complex<T>&);
-template<class T> bool operator!=(const complex<T>&, const T&);
-template<class T> bool operator!=(const T&, const complex<T>&);
+template<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14
+template<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14
+template<class T> bool operator==(const T&, const complex<T>&); // constexpr in C++14
+template<class T> bool operator!=(const complex<T>&, const complex<T>&); // constexpr in C++14
+template<class T> bool operator!=(const complex<T>&, const T&); // constexpr in C++14
+template<class T> bool operator!=(const T&, const complex<T>&); // constexpr in C++14
template<class T, class charT, class traits>
basic_istream<charT, traits>&
@@ -165,17 +165,17 @@ template<class T, class charT, class tra
// 26.3.7 values:
-template<class T> T real(const complex<T>&);
- long double real(long double);
- double real(double);
-template<Integral T> double real(T);
- float real(float);
-
-template<class T> T imag(const complex<T>&);
- long double imag(long double);
- double imag(double);
-template<Integral T> double imag(T);
- float imag(float);
+template<class T> T real(const complex<T>&); // constexpr in C++14
+ long double real(long double); // constexpr in C++14
+ double real(double); // constexpr in C++14
+template<Integral T> double real(T); // constexpr in C++14
+ float real(float); // constexpr in C++14
+
+template<class T> T imag(const complex<T>&); // constexpr in C++14
+ long double imag(long double); // constexpr in C++14
+ double imag(double); // constexpr in C++14
+template<Integral T> double imag(T); // constexpr in C++14
+ float imag(float); // constexpr in C++14
template<class T> T abs(const complex<T>&);
@@ -269,15 +269,15 @@ private:
value_type __re_;
value_type __im_;
public:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
complex(const value_type& __re = value_type(), const value_type& __im = value_type())
: __re_(__re), __im_(__im) {}
- template<class _Xp> _LIBCPP_INLINE_VISIBILITY
+ template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
complex(const complex<_Xp>& __c)
: __re_(__c.real()), __im_(__c.imag()) {}
- _LIBCPP_INLINE_VISIBILITY value_type real() const {return __re_;}
- _LIBCPP_INLINE_VISIBILITY value_type imag() const {return __im_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type real() const {return __re_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type imag() const {return __im_;}
_LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
_LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
@@ -309,12 +309,12 @@ public:
}
template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
{
- *this = *this * __c;
+ *this = *this * complex(__c.real(), __c.imag());
return *this;
}
template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
{
- *this = *this / __c;
+ *this = *this / complex(__c.real(), __c.imag());
return *this;
}
};
@@ -368,12 +368,12 @@ public:
}
template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
{
- *this = *this * __c;
+ *this = *this * complex(__c.real(), __c.imag());
return *this;
}
template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
{
- *this = *this / __c;
+ *this = *this / complex(__c.real(), __c.imag());
return *this;
}
};
@@ -424,12 +424,12 @@ public:
}
template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
{
- *this = *this * __c;
+ *this = *this * complex(__c.real(), __c.imag());
return *this;
}
template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
{
- *this = *this / __c;
+ *this = *this / complex(__c.real(), __c.imag());
return *this;
}
};
@@ -480,12 +480,12 @@ public:
}
template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
{
- *this = *this * __c;
+ *this = *this * complex(__c.real(), __c.imag());
return *this;
}
template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
{
- *this = *this / __c;
+ *this = *this / complex(__c.real(), __c.imag());
return *this;
}
};
@@ -740,7 +740,7 @@ operator-(const complex<_Tp>& __x)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
@@ -748,7 +748,7 @@ operator==(const complex<_Tp>& __x, cons
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator==(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -756,7 +756,7 @@ operator==(const complex<_Tp>& __x, cons
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator==(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -764,7 +764,7 @@ operator==(const _Tp& __x, const complex
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
@@ -772,7 +772,7 @@ operator!=(const complex<_Tp>& __x, cons
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator!=(const complex<_Tp>& __x, const _Tp& __y)
{
@@ -780,7 +780,7 @@ operator!=(const complex<_Tp>& __x, cons
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator!=(const _Tp& __x, const complex<_Tp>& __y)
{
@@ -792,21 +792,21 @@ operator!=(const _Tp& __x, const complex
// real
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
real(const complex<_Tp>& __c)
{
return __c.real();
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
long double
real(long double __re)
{
return __re;
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
double
real(double __re)
{
@@ -814,7 +814,7 @@ real(double __re)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename enable_if
<
is_integral<_Tp>::value,
@@ -825,7 +825,7 @@ real(_Tp __re)
return __re;
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
float
real(float __re)
{
@@ -835,21 +835,21 @@ real(float __re)
// imag
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
imag(const complex<_Tp>& __c)
{
return __c.imag();
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
long double
imag(long double __re)
{
return 0;
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
double
imag(double __re)
{
@@ -857,7 +857,7 @@ imag(double __re)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename enable_if
<
is_integral<_Tp>::value,
@@ -868,7 +868,7 @@ imag(_Tp __re)
return 0;
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
float
imag(float __re)
{
Modified: libcxx/trunk/test/numerics/complex.number/cmplx.over/imag.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/cmplx.over/imag.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/cmplx.over/imag.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/cmplx.over/imag.pass.cpp Wed Jul 31 16:02:34 2013
@@ -19,29 +19,41 @@
#include "../cases.h"
-template <class T>
+template <class T, int x>
void
-test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0)
{
- static_assert((std::is_same<decltype(std::imag(x)), double>::value), "");
+ static_assert((std::is_same<decltype(std::imag(T(x))), double>::value), "");
assert(std::imag(x) == 0);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::imag(val) == 0, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.imag() == x, "" );
+#endif
}
-template <class T>
+template <class T, int x>
void
-test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
{
- static_assert((std::is_same<decltype(std::imag(x)), T>::value), "");
+ static_assert((std::is_same<decltype(std::imag(T(x))), T>::value), "");
assert(std::imag(x) == 0);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::imag(val) == 0, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.imag() == x, "" );
+#endif
}
template <class T>
void
test()
{
- test<T>(0);
- test<T>(1);
- test<T>(10);
+ test<T, 0>();
+ test<T, 1>();
+ test<T, 10>();
}
int main()
Modified: libcxx/trunk/test/numerics/complex.number/cmplx.over/real.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/cmplx.over/real.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/cmplx.over/real.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/cmplx.over/real.pass.cpp Wed Jul 31 16:02:34 2013
@@ -19,29 +19,41 @@
#include "../cases.h"
-template <class T>
+template <class T, int x>
void
-test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0)
{
- static_assert((std::is_same<decltype(std::real(x)), double>::value), "");
+ static_assert((std::is_same<decltype(std::real(T(x))), double>::value), "");
assert(std::real(x) == x);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::real(val) == val, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.real() == x, "" );
+#endif
}
-template <class T>
+template <class T, int x>
void
-test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
{
- static_assert((std::is_same<decltype(std::real(x)), T>::value), "");
+ static_assert((std::is_same<decltype(std::real(T(x))), T>::value), "");
assert(std::real(x) == x);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::real(val) == val, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.real() == x, "" );
+#endif
}
template <class T>
void
test()
{
- test<T>(0);
- test<T>(1);
- test<T>(10);
+ test<T, 0>();
+ test<T, 1>();
+ test<T, 10>();
}
int main()
Modified: libcxx/trunk/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp Wed Jul 31 16:02:34 2013
@@ -28,6 +28,21 @@ test()
c /= c2;
assert(c.real() == 1);
assert(c.imag() == 0);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 /= ic;
+ assert(c3.real() == 0.5);
+ assert(c3.imag() == -0.5);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 /= fc;
+ assert(c3.real() == 0.5);
+ assert(c3.imag() == -0.5);
+
}
int main()
Modified: libcxx/trunk/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp Wed Jul 31 16:02:34 2013
@@ -28,6 +28,20 @@ test()
c -= c2;
assert(c.real() == -3);
assert(c.imag() == -5);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 -= ic;
+ assert(c3.real() == -4);
+ assert(c3.imag() == -6);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 -= fc;
+ assert(c3.real() == -4);
+ assert(c3.imag() == -6);
}
int main()
Modified: libcxx/trunk/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp Wed Jul 31 16:02:34 2013
@@ -28,6 +28,20 @@ test()
c += c2;
assert(c.real() == 3);
assert(c.imag() == 5);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 += ic;
+ assert(c3.real() == 4);
+ assert(c3.imag() == 6);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 += fc;
+ assert(c3.real() == 4);
+ assert(c3.imag() == 6);
}
int main()
Modified: libcxx/trunk/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp Wed Jul 31 16:02:34 2013
@@ -28,6 +28,20 @@ test()
c *= c2;
assert(c.real() == -4);
assert(c.imag() == 7.5);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 *= ic;
+ assert(c3.real() == -11.5);
+ assert(c3.imag() == 3.5);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 *= fc;
+ assert(c3.real() == -11.5);
+ assert(c3.imag() == 3.5);
}
int main()
Modified: libcxx/trunk/test/numerics/complex.number/complex.members/real_imag.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.members/real_imag.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.members/real_imag.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.members/real_imag.pass.cpp Wed Jul 31 16:02:34 2013
@@ -17,6 +17,23 @@
template <class T>
void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ constexpr std::complex<T> c1;
+ static_assert(c1.real() == 0, "");
+ static_assert(c1.imag() == 0, "");
+ constexpr std::complex<T> c2(3);
+ static_assert(c2.real() == 3, "");
+ static_assert(c2.imag() == 0, "");
+ constexpr std::complex<T> c3(3, 4);
+ static_assert(c3.real() == 3, "");
+ static_assert(c3.imag() == 4, "");
+#endif
+}
+
+template <class T>
+void
test()
{
std::complex<T> c;
@@ -34,6 +51,8 @@ test()
c.imag(-5.5);
assert(c.real() == -4.5);
assert(c.imag() == -5.5);
+
+ test_constexpr<T> ();
}
int main()
@@ -41,4 +60,5 @@ int main()
test<float>();
test<double>();
test<long double>();
+ test_constexpr<int> ();
}
Modified: libcxx/trunk/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp Wed Jul 31 16:02:34 2013
@@ -18,9 +18,20 @@
template <class T>
void
-test(const std::complex<T>& lhs, const std::complex<T>& rhs, bool x)
+test_constexpr()
{
- assert((lhs == rhs) == x);
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, -2.5);
+ static_assert( !(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(lhs == rhs, "");
+ }
+#endif
}
template <class T>
@@ -30,13 +41,14 @@ test()
{
std::complex<T> lhs(1.5, 2.5);
std::complex<T> rhs(1.5, -2.5);
- test(lhs, rhs, false);
+ assert( !(lhs == rhs));
}
{
std::complex<T> lhs(1.5, 2.5);
std::complex<T> rhs(1.5, 2.5);
- test(lhs, rhs, true);
+ assert(lhs == rhs);
}
+ test_constexpr<T> ();
}
int main()
@@ -44,4 +56,5 @@ int main()
test<float>();
test<double>();
test<long double>();
+// test_constexpr<int> ();
}
Modified: libcxx/trunk/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp Wed Jul 31 16:02:34 2013
@@ -18,9 +18,30 @@
template <class T>
void
-test(const std::complex<T>& lhs, const T& rhs, bool x)
+test_constexpr()
{
- assert((lhs == rhs) == x);
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(-2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(-2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(1.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(1.5);
+ static_assert( (lhs == rhs), "");
+ }
+#endif
}
template <class T>
@@ -30,28 +51,31 @@ test()
{
std::complex<T> lhs(1.5, 2.5);
T rhs(-2.5);
- test(lhs, rhs, false);
+ assert(!(lhs == rhs));
}
{
- std::complex<T> lhs(1.5, 0);
+ std::complex<T> lhs(1.5, 0);
T rhs(-2.5);
- test(lhs, rhs, false);
+ assert(!(lhs == rhs));
}
{
std::complex<T> lhs(1.5, 2.5);
T rhs(1.5);
- test(lhs, rhs, false);
+ assert(!(lhs == rhs));
}
{
std::complex<T> lhs(1.5, 0);
T rhs(1.5);
- test(lhs, rhs, true);
+ assert( (lhs == rhs));
+ }
+
+ test_constexpr<T> ();
}
-}
int main()
{
test<float>();
test<double>();
test<long double>();
+// test_constexpr<int> ();
}
Modified: libcxx/trunk/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp Wed Jul 31 16:02:34 2013
@@ -18,11 +18,23 @@
template <class T>
void
-test(const std::complex<T>& lhs, const std::complex<T>& rhs, bool x)
+test_constexpr()
{
- assert((lhs != rhs) == x);
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, -2.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(!(lhs != rhs), "" );
+ }
+#endif
}
+
template <class T>
void
test()
@@ -30,18 +42,21 @@ test()
{
std::complex<T> lhs(1.5, 2.5);
std::complex<T> rhs(1.5, -2.5);
- test(lhs, rhs, true);
+ assert(lhs != rhs);
}
{
std::complex<T> lhs(1.5, 2.5);
std::complex<T> rhs(1.5, 2.5);
- test(lhs, rhs, false);
+ assert(!(lhs != rhs));
}
-}
+
+ test_constexpr<T> ();
+ }
int main()
{
test<float>();
test<double>();
test<long double>();
+// test_constexpr<int> ();
}
Modified: libcxx/trunk/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp Wed Jul 31 16:02:34 2013
@@ -18,9 +18,30 @@
template <class T>
void
-test(const std::complex<T>& lhs, const T& rhs, bool x)
+test_constexpr()
{
- assert((lhs != rhs) == x);
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(-2.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(-2.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(1.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(1.5);
+ static_assert( !(lhs != rhs), "");
+ }
+#endif
}
template <class T>
@@ -30,23 +51,25 @@ test()
{
std::complex<T> lhs(1.5, 2.5);
T rhs(-2.5);
- test(lhs, rhs, true);
+ assert(lhs != rhs);
}
{
std::complex<T> lhs(1.5, 0);
T rhs(-2.5);
- test(lhs, rhs, true);
+ assert(lhs != rhs);
}
{
std::complex<T> lhs(1.5, 2.5);
T rhs(1.5);
- test(lhs, rhs, true);
+ assert(lhs != rhs);
}
{
std::complex<T> lhs(1.5, 0);
T rhs(1.5);
- test(lhs, rhs, false);
+ assert( !(lhs != rhs));
}
+
+ test_constexpr<T> ();
}
int main()
@@ -54,4 +77,5 @@ int main()
test<float>();
test<double>();
test<long double>();
-}
+// test_constexpr<int> ();
+ }
Modified: libcxx/trunk/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp Wed Jul 31 16:02:34 2013
@@ -18,9 +18,30 @@
template <class T>
void
-test(const T& lhs, const std::complex<T>& rhs, bool x)
+test_constexpr()
{
- assert((lhs == rhs) == x);
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert(lhs == rhs, "");
+ }
+#endif
}
template <class T>
@@ -30,23 +51,25 @@ test()
{
T lhs(-2.5);
std::complex<T> rhs(1.5, 2.5);
- test(lhs, rhs, false);
+ assert(!(lhs == rhs));
}
{
T lhs(-2.5);
std::complex<T> rhs(1.5, 0);
- test(lhs, rhs, false);
+ assert(!(lhs == rhs));
}
{
T lhs(1.5);
std::complex<T> rhs(1.5, 2.5);
- test(lhs, rhs, false);
+ assert(!(lhs == rhs));
}
{
T lhs(1.5);
std::complex<T> rhs(1.5, 0);
- test(lhs, rhs, true);
+ assert(lhs == rhs);
}
+
+ test_constexpr<T> ();
}
int main()
@@ -54,4 +77,5 @@ int main()
test<float>();
test<double>();
test<long double>();
+// test_constexpr<int>();
}
Modified: libcxx/trunk/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp?rev=187529&r1=187528&r2=187529&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp Wed Jul 31 16:02:34 2013
@@ -18,9 +18,30 @@
template <class T>
void
-test(const T& lhs, const std::complex<T>& rhs, bool x)
+test_constexpr()
{
- assert((lhs != rhs) == x);
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert (lhs != rhs, "");
+ }
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert (lhs != rhs, "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert (lhs != rhs, "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert (!(lhs != rhs), "");
+ }
+#endif
}
template <class T>
@@ -30,28 +51,31 @@ test()
{
T lhs(-2.5);
std::complex<T> rhs(1.5, 2.5);
- test(lhs, rhs, true);
+ assert (lhs != rhs);
}
{
T lhs(-2.5);
std::complex<T> rhs(1.5, 0);
- test(lhs, rhs, true);
+ assert (lhs != rhs);
}
{
T lhs(1.5);
std::complex<T> rhs(1.5, 2.5);
- test(lhs, rhs, true);
+ assert (lhs != rhs);
}
{
T lhs(1.5);
std::complex<T> rhs(1.5, 0);
- test(lhs, rhs, false);
+ assert (!(lhs != rhs));
+ }
+
+ test_constexpr<T> ();
}
-}
int main()
{
test<float>();
test<double>();
test<long double>();
+// test_constexpr<int>();
}
More information about the cfe-commits
mailing list