[cfe-commits] [libcxx] r160585 - in /libcxx/trunk: include/ test/numerics/complex.number/complex.members/ test/numerics/complex.number/complex.special/

Howard Hinnant hhinnant at apple.com
Fri Jul 20 15:18:28 PDT 2012


Author: hhinnant
Date: Fri Jul 20 17:18:27 2012
New Revision: 160585

URL: http://llvm.org/viewvc/llvm-project?rev=160585&view=rev
Log:
constexpr applied to <complex>.

Modified:
    libcxx/trunk/include/complex
    libcxx/trunk/test/numerics/complex.number/complex.members/construct.pass.cpp
    libcxx/trunk/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp
    libcxx/trunk/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp
    libcxx/trunk/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp
    libcxx/trunk/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp
    libcxx/trunk/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp
    libcxx/trunk/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp
    libcxx/trunk/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp
    libcxx/trunk/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp
    libcxx/trunk/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp

Modified: libcxx/trunk/include/complex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/complex?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/include/complex (original)
+++ libcxx/trunk/include/complex Fri Jul 20 17:18:27 2012
@@ -330,13 +330,13 @@
 public:
     typedef float value_type;
 
-    /*constexpr*/ _LIBCPP_INLINE_VISIBILITY complex(float __re = 0.0f, float __im = 0.0f)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f)
         : __re_(__re), __im_(__im) {}
-    explicit /*constexpr*/ complex(const complex<double>& __c);
-    explicit /*constexpr*/ complex(const complex<long double>& __c);
+    explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
+    explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
 
-    /*constexpr*/ _LIBCPP_INLINE_VISIBILITY float real() const {return __re_;}
-    /*constexpr*/ _LIBCPP_INLINE_VISIBILITY float imag() const {return __im_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float imag() const {return __im_;}
 
     _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
     _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
@@ -386,13 +386,13 @@
 public:
     typedef double value_type;
 
-    /*constexpr*/ _LIBCPP_INLINE_VISIBILITY complex(double __re = 0.0, double __im = 0.0)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0)
         : __re_(__re), __im_(__im) {}
-    /*constexpr*/ complex(const complex<float>& __c);
-    explicit /*constexpr*/ complex(const complex<long double>& __c);
+    _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
+    explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
 
-    /*constexpr*/ _LIBCPP_INLINE_VISIBILITY double real() const {return __re_;}
-    /*constexpr*/ _LIBCPP_INLINE_VISIBILITY double imag() const {return __im_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double imag() const {return __im_;}
 
     _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
     _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
@@ -442,13 +442,13 @@
 public:
     typedef long double value_type;
 
-    /*constexpr*/ _LIBCPP_INLINE_VISIBILITY complex(long double __re = 0.0L, long double __im = 0.0L)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L)
         : __re_(__re), __im_(__im) {}
-    /*constexpr*/ complex(const complex<float>& __c);
-    /*constexpr*/ complex(const complex<double>& __c);
+    _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
+    _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
 
-    /*constexpr*/ _LIBCPP_INLINE_VISIBILITY long double real() const {return __re_;}
-    /*constexpr*/ _LIBCPP_INLINE_VISIBILITY long double imag() const {return __im_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double imag() const {return __im_;}
 
     _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
     _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
@@ -490,33 +490,33 @@
         }
 };
 
-//constexpr
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
 complex<float>::complex(const complex<double>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 
-//constexpr
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
 complex<float>::complex(const complex<long double>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 
-//constexpr
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
 complex<double>::complex(const complex<float>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 
-//constexpr
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
 complex<double>::complex(const complex<long double>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 
-//constexpr
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
 complex<long double>::complex(const complex<float>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 
-//constexpr
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
 complex<long double>::complex(const complex<double>& __c)
     : __re_(__c.real()), __im_(__c.imag()) {}
 

Modified: libcxx/trunk/test/numerics/complex.number/complex.members/construct.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.members/construct.pass.cpp?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.members/construct.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.members/construct.pass.cpp Fri Jul 20 17:18:27 2012
@@ -9,7 +9,7 @@
 
 // <complex>
 
-// complex(const T& re = T(), const T& im = T());
+// constexpr complex(const T& re = T(), const T& im = T());
 
 #include <complex>
 #include <cassert>
@@ -38,6 +38,28 @@
     assert(c.real() == 10.5);
     assert(c.imag() == -9.5);
     }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<T> c;
+    static_assert(c.real() == 0, "");
+    static_assert(c.imag() == 0, "");
+    }
+    {
+    constexpr std::complex<T> c = 7.5;
+    static_assert(c.real() == 7.5, "");
+    static_assert(c.imag() == 0, "");
+    }
+    {
+    constexpr std::complex<T> c(8.5);
+    static_assert(c.real() == 8.5, "");
+    static_assert(c.imag() == 0, "");
+    }
+    {
+    constexpr std::complex<T> c(10.5, -9.5);
+    static_assert(c.real() == 10.5, "");
+    static_assert(c.imag() == -9.5, "");
+    }
+#endif
 }
 
 int main()

Modified: libcxx/trunk/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp Fri Jul 20 17:18:27 2012
@@ -20,8 +20,18 @@
 
 int main()
 {
+    {
     const std::complex<float> cd(2.5, 3.5);
     std::complex<double> cf(cd);
     assert(cf.real() == cd.real());
     assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<float> cd(2.5, 3.5);
+    constexpr std::complex<double> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp Fri Jul 20 17:18:27 2012
@@ -20,8 +20,18 @@
 
 int main()
 {
+    {
     const std::complex<float> cd(2.5, 3.5);
     std::complex<double> cf = cd;
     assert(cf.real() == cd.real());
     assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<float> cd(2.5, 3.5);
+    constexpr std::complex<double> cf = cd;
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp Fri Jul 20 17:18:27 2012
@@ -20,8 +20,18 @@
 
 int main()
 {
+    {
     const std::complex<long double> cd(2.5, 3.5);
     std::complex<double> cf(cd);
     assert(cf.real() == cd.real());
     assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<long double> cd(2.5, 3.5);
+    constexpr std::complex<double> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp Fri Jul 20 17:18:27 2012
@@ -20,8 +20,18 @@
 
 int main()
 {
+    {
     const std::complex<double> cd(2.5, 3.5);
     std::complex<float> cf(cd);
     assert(cf.real() == cd.real());
     assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<double> cd(2.5, 3.5);
+    constexpr std::complex<float> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp Fri Jul 20 17:18:27 2012
@@ -20,8 +20,18 @@
 
 int main()
 {
+    {
     const std::complex<long double> cd(2.5, 3.5);
     std::complex<float> cf(cd);
     assert(cf.real() == cd.real());
     assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<long double> cd(2.5, 3.5);
+    constexpr std::complex<float> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp Fri Jul 20 17:18:27 2012
@@ -20,8 +20,18 @@
 
 int main()
 {
+    {
     const std::complex<double> cd(2.5, 3.5);
     std::complex<long double> cf(cd);
     assert(cf.real() == cd.real());
     assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<double> cd(2.5, 3.5);
+    constexpr std::complex<long double> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp Fri Jul 20 17:18:27 2012
@@ -20,8 +20,18 @@
 
 int main()
 {
+    {
     const std::complex<double> cd(2.5, 3.5);
     std::complex<long double> cf = cd;
     assert(cf.real() == cd.real());
     assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<double> cd(2.5, 3.5);
+    constexpr std::complex<long double> cf = cd;
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp Fri Jul 20 17:18:27 2012
@@ -20,8 +20,18 @@
 
 int main()
 {
+    {
     const std::complex<float> cd(2.5, 3.5);
     std::complex<long double> cf(cd);
     assert(cf.real() == cd.real());
     assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<float> cd(2.5, 3.5);
+    constexpr std::complex<long double> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
 }

Modified: libcxx/trunk/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp?rev=160585&r1=160584&r2=160585&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp Fri Jul 20 17:18:27 2012
@@ -20,8 +20,18 @@
 
 int main()
 {
+    {
     const std::complex<float> cd(2.5, 3.5);
     std::complex<long double> cf = cd;
     assert(cf.real() == cd.real());
     assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<float> cd(2.5, 3.5);
+    constexpr std::complex<long double> cf = cd;
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
 }





More information about the cfe-commits mailing list