summaryrefslogtreecommitdiffstats
path: root/libcxx/include/vector
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2019-03-15 00:29:35 +0000
committerMarshall Clow <mclow.lists@gmail.com>2019-03-15 00:29:35 +0000
commit5bcca9ffd167a50dafa2c3958b36e498ee71ad68 (patch)
treeacd2ea0df1089cbfada6511793b6280ce95c031f /libcxx/include/vector
parentf2192b204ff49561cc73fe06a76216f3cab39d84 (diff)
downloadbcm5719-llvm-5bcca9ffd167a50dafa2c3958b36e498ee71ad68.tar.gz
bcm5719-llvm-5bcca9ffd167a50dafa2c3958b36e498ee71ad68.zip
Mark vector::operator[] and front/back as noexcept. We already do this for string and string_view. This should give better codegen inside of noexcept functions. Add tests for op[]/front/back/at, because apparently we had none.
llvm-svn: 356224
Diffstat (limited to 'libcxx/include/vector')
-rw-r--r--libcxx/include/vector16
1 files changed, 8 insertions, 8 deletions
diff --git a/libcxx/include/vector b/libcxx/include/vector
index 79d17675a8c..8413d89bb73 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -664,27 +664,27 @@ public:
void reserve(size_type __n);
void shrink_to_fit() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n);
- _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const;
+ _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;
reference at(size_type __n);
const_reference at(size_type __n) const;
- _LIBCPP_INLINE_VISIBILITY reference front()
+ _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "front() called for empty vector");
return *this->__begin_;
}
- _LIBCPP_INLINE_VISIBILITY const_reference front() const
+ _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "front() called for empty vector");
return *this->__begin_;
}
- _LIBCPP_INLINE_VISIBILITY reference back()
+ _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "back() called for empty vector");
return *(this->__end_ - 1);
}
- _LIBCPP_INLINE_VISIBILITY const_reference back() const
+ _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "back() called for empty vector");
return *(this->__end_ - 1);
@@ -1537,7 +1537,7 @@ vector<_Tp, _Allocator>::end() const _NOEXCEPT
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::reference
-vector<_Tp, _Allocator>::operator[](size_type __n)
+vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds");
return this->__begin_[__n];
@@ -1546,7 +1546,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n)
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_reference
-vector<_Tp, _Allocator>::operator[](size_type __n) const
+vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds");
return this->__begin_[__n];
OpenPOWER on IntegriCloud