[cfe-commits] [libcxx] r160564 - in /libcxx/trunk: include/array test/containers/sequences/array/array.size/size.pass.cpp

Howard Hinnant hhinnant at apple.com
Fri Jul 20 12:20:49 PDT 2012


Author: hhinnant
Date: Fri Jul 20 14:20:49 2012
New Revision: 160564

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

Modified:
    libcxx/trunk/include/array
    libcxx/trunk/test/containers/sequences/array/array.size/size.pass.cpp

Modified: libcxx/trunk/include/array
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=160564&r1=160563&r2=160564&view=diff
==============================================================================
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Fri Jul 20 14:20:49 2012
@@ -55,7 +55,7 @@
     // capacity:
     constexpr size_type size() const noexcept;
     constexpr size_type max_size() const noexcept;
-    bool empty() const noexcept;
+    constexpr bool empty() const noexcept;
 
     // element access:
     reference operator[](size_type n);
@@ -173,11 +173,11 @@
 
     // capacity:
     _LIBCPP_INLINE_VISIBILITY
-    /*constexpr*/ size_type size() const _NOEXCEPT {return _Size;}
+    _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
     _LIBCPP_INLINE_VISIBILITY
-    /*constexpr*/ size_type max_size() const _NOEXCEPT {return _Size;}
+    _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
     _LIBCPP_INLINE_VISIBILITY
-    bool empty() const _NOEXCEPT {return _Size == 0;}
+    _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
 
     // element access:
     _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n)             {return __elems_[__n];}

Modified: libcxx/trunk/test/containers/sequences/array/array.size/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/array/array.size/size.pass.cpp?rev=160564&r1=160563&r2=160564&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/array/array.size/size.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/array/array.size/size.pass.cpp Fri Jul 20 14:20:49 2012
@@ -28,4 +28,18 @@
         C c = {};
         assert(c.size() == 0);
     }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        constexpr C c = {1, 2, 3.5};
+        static_assert(c.size() == 3, "");
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        constexpr C c = {};
+        static_assert(c.size() == 0, "");
+    }
+#endif
 }





More information about the cfe-commits mailing list