Mark 'front()' and 'back()' as noexcept for array/deque/string/string_view. These are just rebranded 'operator[]', and should be noexcept like it is.
llvm-svn: 356435
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 9ea0e473f0b96455b918eefcf8fc535638674a1f
diff --git a/include/string b/include/string
index ab6052d..3b01c41 100644
--- a/include/string
+++ b/include/string
@@ -1060,10 +1060,10 @@
void push_back(value_type __c);
_LIBCPP_INLINE_VISIBILITY
void pop_back();
- _LIBCPP_INLINE_VISIBILITY reference front();
- _LIBCPP_INLINE_VISIBILITY const_reference front() const;
- _LIBCPP_INLINE_VISIBILITY reference back();
- _LIBCPP_INLINE_VISIBILITY const_reference back() const;
+ _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT;
template <class _Tp>
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
@@ -3237,7 +3237,7 @@
template <class _CharT, class _Traits, class _Allocator>
inline
typename basic_string<_CharT, _Traits, _Allocator>::reference
-basic_string<_CharT, _Traits, _Allocator>::front()
+basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
return *__get_pointer();
@@ -3246,7 +3246,7 @@
template <class _CharT, class _Traits, class _Allocator>
inline
typename basic_string<_CharT, _Traits, _Allocator>::const_reference
-basic_string<_CharT, _Traits, _Allocator>::front() const
+basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
return *data();
@@ -3255,7 +3255,7 @@
template <class _CharT, class _Traits, class _Allocator>
inline
typename basic_string<_CharT, _Traits, _Allocator>::reference
-basic_string<_CharT, _Traits, _Allocator>::back()
+basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
return *(__get_pointer() + size() - 1);
@@ -3264,7 +3264,7 @@
template <class _CharT, class _Traits, class _Allocator>
inline
typename basic_string<_CharT, _Traits, _Allocator>::const_reference
-basic_string<_CharT, _Traits, _Allocator>::back() const
+basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
return *(data() + size() - 1);