diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2017-01-16 03:02:10 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2017-01-16 03:02:10 +0000 |
commit | e78269506fe5209a64b8b956d5c12c58bf02fb56 (patch) | |
tree | 24721e0f0d184a9d69f9b54503ec38ad71b4dd98 /libcxx/test/std/containers/sequences/array | |
parent | c9807c3370568e970fa3659c5e973b57afe78365 (diff) | |
download | bcm5719-llvm-e78269506fe5209a64b8b956d5c12c58bf02fb56.tar.gz bcm5719-llvm-e78269506fe5209a64b8b956d5c12c58bf02fb56.zip |
Implement the missing constexpr stuff in <array>. Fixes PR#31645.
llvm-svn: 292091
Diffstat (limited to 'libcxx/test/std/containers/sequences/array')
3 files changed, 53 insertions, 3 deletions
diff --git a/libcxx/test/std/containers/sequences/array/at.pass.cpp b/libcxx/test/std/containers/sequences/array/at.pass.cpp index 29483153d4a..8e7ff6dff70 100644 --- a/libcxx/test/std/containers/sequences/array/at.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/at.pass.cpp @@ -23,6 +23,14 @@ // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" +#if TEST_STD_VER > 14 +constexpr bool check_idx( size_t idx, double val ) +{ + std::array<double, 3> arr = {1, 2, 3.5}; + return arr.at(idx) == val; +} +#endif + int main() { { @@ -82,4 +90,11 @@ int main() } #endif +#if TEST_STD_VER > 14 + { + static_assert (check_idx(0, 1), ""); + static_assert (check_idx(1, 2), ""); + static_assert (check_idx(2, 3.5), ""); + } +#endif } diff --git a/libcxx/test/std/containers/sequences/array/front_back.pass.cpp b/libcxx/test/std/containers/sequences/array/front_back.pass.cpp index 7d53b8265e9..239fda5c99d 100644 --- a/libcxx/test/std/containers/sequences/array/front_back.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/front_back.pass.cpp @@ -9,10 +9,10 @@ // <array> -// reference front(); -// reference back(); +// reference front(); // constexpr in C++17 +// reference back(); // constexpr in C++17 // const_reference front(); // constexpr in C++14 -// const_reference back(); // constexpr in C++14 +// const_reference back(); // constexpr in C++14 #include <array> #include <cassert> @@ -23,6 +23,20 @@ // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" +#if TEST_STD_VER > 14 +constexpr bool check_front( double val ) +{ + std::array<double, 3> arr = {1, 2, 3.5}; + return arr.front() == val; +} + +constexpr bool check_back( double val ) +{ + std::array<double, 3> arr = {1, 2, 3.5}; + return arr.back() == val; +} +#endif + int main() { { @@ -65,4 +79,10 @@ int main() } #endif +#if TEST_STD_VER > 14 + { + static_assert (check_front(1), ""); + static_assert (check_back (3.5), ""); + } +#endif } diff --git a/libcxx/test/std/containers/sequences/array/indexing.pass.cpp b/libcxx/test/std/containers/sequences/array/indexing.pass.cpp index 64d2716a759..6cb7941d92c 100644 --- a/libcxx/test/std/containers/sequences/array/indexing.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/indexing.pass.cpp @@ -23,6 +23,14 @@ // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" +#if TEST_STD_VER > 14 +constexpr bool check_idx( size_t idx, double val ) +{ + std::array<double, 3> arr = {1, 2, 3.5}; + return arr[idx] == val; +} +#endif + int main() { { @@ -63,4 +71,11 @@ int main() } #endif +#if TEST_STD_VER > 14 + { + static_assert (check_idx(0, 1), ""); + static_assert (check_idx(1, 2), ""); + static_assert (check_idx(2, 3.5), ""); + } +#endif } |