std::basic_string<CharT,Traits,Allocator>::ends_with
cppreference.com
<tbody>
</tbody>
constexpr bool ends_with( std::basic_string_view<CharT, Traits> sv ) const noexcept; |
(1) | ( C++20) |
constexpr bool ends_with( CharT ch ) const noexcept; |
(2) | ( C++20) |
constexpr bool ends_with( const CharT* s ) const; |
(3) | ( C++20) |
, . :
1)
sv ( std::basic_string).2)
ch.3)
s, . std::basic_string_view<CharT, Traits>(data(), size()).ends_with(x), x .
| sv | , std::basic_string
| |
| ch | ||
| s | , |
true, , false .
__cpp_lib_starts_ends_with |
201711L |
(C++20) | : starts_with() ends_with() |
#include <cassert>
#include <string>
#include <string_view>
int main()
{
using namespace std::literals;
const auto str = "Hello, C++20!"s;
assert
(""
&& str.ends_with("C++20!"sv) // (1)
&& !str.ends_with("c++20!"sv) // (1)
&& str.ends_with("C++20!"s) // (1) string_view
&& !str.ends_with("c++20!"s) // (1) string_view
&& str.ends_with('!') // (2)
&& !str.ends_with('?') // (2)
&& str.ends_with("C++20!") // (3)
&& !str.ends_with("c++20!") // (3)
);
}
(C++20) |
, (public -) |
(C++20) |
, (public - std::basic_string_view<CharT,Traits>)
|
(C++20) |
, (public - std::basic_string_view<CharT,Traits>)
|
(C++23) |
, (public -) |
(C++23) |
, (public - std::basic_string_view<CharT,Traits>)
|
| (public -) | |
| (public -) |