std::basic_string_view<CharT,Traits>:: back
|
constexpr
const_reference back
(
)
const
;
|
(C++17以降) | |
ビューの最後の文字への参照を返します。
|
empty() が true の場合、動作は未定義です。 |
(C++26まで) |
|
empty() が true の場合:
|
(C++26以降) |
目次 |
戻り値
data_
[
size
(
)
-
1
]
計算量
定数。
例
#include <iostream> #include <string_view> int main() { for (std::string_view str{"ABCDEF"}; !str.empty(); str.remove_suffix(1)) std::cout << str.back() << ' ' << str << '\n'; }
出力:
F ABCDEF E ABCDE D ABCD C ABC B AB A A
関連項目
|
最初の文字にアクセスする
(public member function) |
|
|
ビューが空かどうかをチェックする
(public member function) |
|
|
(
DR*
)
|
最後の文字にアクセスする
(public member function of
std::basic_string<CharT,Traits,Allocator>
)
|