summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/sequences/array/indexing.pass.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2019-03-14 21:56:57 +0000
committerMarshall Clow <mclow.lists@gmail.com>2019-03-14 21:56:57 +0000
commit5f6a5ac19cddda2fbc67582d6b12a92493e60b4e (patch)
treea16ea9055eeaab30076137a79f6b79c0b735f965 /libcxx/test/std/containers/sequences/array/indexing.pass.cpp
parent7f7867b05ab763d17b4017cf51f089523d475654 (diff)
downloadbcm5719-llvm-5f6a5ac19cddda2fbc67582d6b12a92493e60b4e.tar.gz
bcm5719-llvm-5f6a5ac19cddda2fbc67582d6b12a92493e60b4e.zip
Add noexcept to operator[] for array and deque. This is an extension. We already do this for string and string_view. This should give better codegen inside of noexcept functions.
llvm-svn: 356209
Diffstat (limited to 'libcxx/test/std/containers/sequences/array/indexing.pass.cpp')
-rw-r--r--libcxx/test/std/containers/sequences/array/indexing.pass.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/sequences/array/indexing.pass.cpp b/libcxx/test/std/containers/sequences/array/indexing.pass.cpp
index bf55711a141..7bc3360a6fd 100644
--- a/libcxx/test/std/containers/sequences/array/indexing.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/indexing.pass.cpp
@@ -12,6 +12,7 @@
// const_reference operator[] (size_type); // constexpr in C++14
// reference at (size_type)
// const_reference at (size_type); // constexpr in C++14
+// Libc++ marks these as noexcept
#include <array>
#include <cassert>
@@ -36,6 +37,8 @@ int main(int, char**)
typedef double T;
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
+ LIBCPP_ASSERT_NOEXCEPT(c[0]);
+ ASSERT_SAME_TYPE(C::reference, decltype(c[0]));
C::reference r1 = c[0];
assert(r1 == 1);
r1 = 5.5;
@@ -50,6 +53,8 @@ int main(int, char**)
typedef double T;
typedef std::array<T, 3> C;
const C c = {1, 2, 3.5};
+ LIBCPP_ASSERT_NOEXCEPT(c[0]);
+ ASSERT_SAME_TYPE(C::const_reference, decltype(c[0]));
C::const_reference r1 = c[0];
assert(r1 == 1);
C::const_reference r2 = c[2];
@@ -59,6 +64,8 @@ int main(int, char**)
typedef double T;
typedef std::array<T, 0> C;
C c = {};
+ LIBCPP_ASSERT_NOEXCEPT(c[0]);
+ ASSERT_SAME_TYPE(C::reference, decltype(c[0]));
C const& cc = c;
static_assert((std::is_same<decltype(c[0]), T &>::value), "");
static_assert((std::is_same<decltype(cc[0]), const T &>::value), "");
@@ -73,6 +80,8 @@ int main(int, char**)
typedef double T;
typedef std::array<const T, 0> C;
C c = {{}};
+ LIBCPP_ASSERT_NOEXCEPT(c[0]);
+ ASSERT_SAME_TYPE(C::reference, decltype(c[0]));
C const& cc = c;
static_assert((std::is_same<decltype(c[0]), const T &>::value), "");
static_assert((std::is_same<decltype(cc[0]), const T &>::value), "");
@@ -88,6 +97,8 @@ int main(int, char**)
typedef double T;
typedef std::array<T, 3> C;
constexpr C c = {1, 2, 3.5};
+ LIBCPP_ASSERT_NOEXCEPT(c[0]);
+ ASSERT_SAME_TYPE(C::const_reference, decltype(c[0]));
constexpr T t1 = c[0];
static_assert (t1 == 1, "");
OpenPOWER on IntegriCloud