diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2017-12-04 20:11:38 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2017-12-04 20:11:38 +0000 |
| commit | 800259c98d6fe81fefabb38c01a79504f2652cf2 (patch) | |
| tree | cc866a4940edef9a6d7bcb0b505433f64756e059 /libcxx/include/string | |
| parent | de4c0ae2055824cd0d861966cfc543e02a97b211 (diff) | |
| download | bcm5719-llvm-800259c98d6fe81fefabb38c01a79504f2652cf2.tar.gz bcm5719-llvm-800259c98d6fe81fefabb38c01a79504f2652cf2.zip | |
Implement P0457R2: 'String Prefix and Suffix Checking' for c++2a
llvm-svn: 319687
Diffstat (limited to 'libcxx/include/string')
| -rw-r--r-- | libcxx/include/string | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libcxx/include/string b/libcxx/include/string index e7142b2b28e..f5d548965aa 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -301,6 +301,13 @@ public: int compare(size_type pos1, size_type n1, const value_type* s) const; int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; + bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++2a + bool starts_with(charT c) const noexcept; // C++2a + bool starts_with(const charT* s) const; // C++2a + bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++2a + bool ends_with(charT c) const noexcept; // C++2a + bool ends_with(const charT* s) const; // C++2a + bool __invariants() const; }; @@ -1215,6 +1222,32 @@ public: int compare(size_type __pos1, size_type __n1, const value_type* __s) const; 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 + { return __self_view(data(), size()).starts_with(__sv); } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _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 + { return starts_with(__self_view(__s)); } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _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 + { return !empty() && _Traits::eq(back(), __c); } + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool ends_with(const value_type* __s) const _NOEXCEPT + { return ends_with(__self_view(__s)); } +#endif + _LIBCPP_INLINE_VISIBILITY bool __invariants() const; _LIBCPP_INLINE_VISIBILITY |

