[libcxx-commits] [libcxx] ae0e037 - [libc++] Simplify the _LIBCPP_CONSTEXPR markings on starts_with() etc.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 29 16:01:15 PDT 2021
Author: Arthur O'Dwyer
Date: 2021-09-29T19:00:58-04:00
New Revision: ae0e037f532b2ac118712c50823348a7acb6f850
URL: https://github.com/llvm/llvm-project/commit/ae0e037f532b2ac118712c50823348a7acb6f850
DIFF: https://github.com/llvm/llvm-project/commit/ae0e037f532b2ac118712c50823348a7acb6f850.diff
LOG: [libc++] Simplify the _LIBCPP_CONSTEXPR markings on starts_with() etc.
This came out of review comments on D110598.
Differential Revision: https://reviews.llvm.org/D110637
Added:
Modified:
libcxx/include/string
libcxx/include/string_view
Removed:
################################################################################
diff --git a/libcxx/include/string b/libcxx/include/string
index 4ca0e86ba808..87e66b68497a 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1406,28 +1406,28 @@ public:
int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
#if _LIBCPP_STD_VER > 17
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool starts_with(__self_view __sv) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(__self_view __sv) const noexcept
{ return __self_view(data(), size()).starts_with(__sv); }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool starts_with(value_type __c) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(value_type __c) const noexcept
{ return !empty() && _Traits::eq(front(), __c); }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool starts_with(const value_type* __s) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(const value_type* __s) const noexcept
{ return starts_with(__self_view(__s)); }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool ends_with(__self_view __sv) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(__self_view __sv) const noexcept
{ return __self_view(data(), size()).ends_with( __sv); }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool ends_with(value_type __c) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(value_type __c) const noexcept
{ return !empty() && _Traits::eq(back(), __c); }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool ends_with(const value_type* __s) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(const value_type* __s) const noexcept
{ return ends_with(__self_view(__s)); }
#endif
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index 2c94cb85269f..33c8d6db7a1e 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -255,10 +255,10 @@ public:
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
- _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
basic_string_view(const basic_string_view&) _NOEXCEPT = default;
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
@@ -618,28 +618,28 @@ public:
}
#if _LIBCPP_STD_VER > 17
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool starts_with(basic_string_view __s) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(basic_string_view __s) const noexcept
{ return size() >= __s.size() && compare(0, __s.size(), __s) == 0; }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool starts_with(value_type __c) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(value_type __c) const noexcept
{ return !empty() && _Traits::eq(front(), __c); }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool starts_with(const value_type* __s) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool starts_with(const value_type* __s) const noexcept
{ return starts_with(basic_string_view(__s)); }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool ends_with(basic_string_view __s) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(basic_string_view __s) const noexcept
{ return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool ends_with(value_type __c) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(value_type __c) const noexcept
{ return !empty() && _Traits::eq(back(), __c); }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool ends_with(const value_type* __s) const _NOEXCEPT
+ constexpr _LIBCPP_INLINE_VISIBILITY
+ bool ends_with(const value_type* __s) const noexcept
{ return ends_with(basic_string_view(__s)); }
#endif
More information about the libcxx-commits
mailing list