[libc++] Complete overhaul of constexpr support in std::array

This commit adds missing support for constexpr in std::array under all
standard modes up to and including C++20. It also transforms the <array>
tests to check for constexpr-friendliness under the right standard modes.

Fixes https://llvm.org/PR40124
Fixes rdar://57522096
Supersedes https://reviews.llvm.org/D60666

Differential Revision: https://reviews.llvm.org/D80452
diff --git a/libcxx/test/std/containers/sequences/array/contiguous.pass.cpp b/libcxx/test/std/containers/sequences/array/contiguous.pass.cpp
index 41a7153..9589e63 100644
--- a/libcxx/test/std/containers/sequences/array/contiguous.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/contiguous.pass.cpp
@@ -15,20 +15,33 @@
 
 #include "test_macros.h"
 
-template <class C>
-void test_contiguous ( const C &c )
+template <class Container>
+TEST_CONSTEXPR_CXX14 void assert_contiguous(Container const& c)
 {
-    for ( size_t i = 0; i < c.size(); ++i )
-        assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+    for (size_t i = 0; i < c.size(); ++i)
+        assert(*(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+}
+
+TEST_CONSTEXPR_CXX17 bool tests()
+{
+    assert_contiguous(std::array<double, 0>());
+    assert_contiguous(std::array<double, 1>());
+    assert_contiguous(std::array<double, 2>());
+    assert_contiguous(std::array<double, 3>());
+
+    assert_contiguous(std::array<char, 0>());
+    assert_contiguous(std::array<char, 1>());
+    assert_contiguous(std::array<char, 2>());
+    assert_contiguous(std::array<char, 3>());
+
+    return true;
 }
 
 int main(int, char**)
 {
-    {
-        typedef double T;
-        typedef std::array<T, 3> C;
-        test_contiguous (C());
-    }
-
-  return 0;
+    tests();
+#if TEST_STD_VER >= 17 // begin() & friends are constexpr in >= C++17 only
+    static_assert(tests(), "");
+#endif
+    return 0;
 }