std::basic_string_view<CharT,Traits>::front
From cppreference.com
< cpp | string | basic string view
| constexpr const_reference front() const; |
(C++17以降) | |
ビューの最初の文字への参照を返します。`empty() == true` の場合、動作は未定義です。
目次 |
[編集] パラメータ
(なし)
[編集] 戻り値
最初の文字への参照。`operator[](0)` と同等です。
[編集] 計算量
定数。
[編集] 例
このコードを実行
#include <iostream> #include <string_view> int main() { for (std::string_view str{"ABCDEF"}; !str.empty(); str.remove_prefix(1)) std::cout << str.front() << ' ' << str << '\n'; }
出力
A ABCDEF B BCDEF C CDEF D DEF E EF F F
[編集] 関連項目
| 最後の文字にアクセスする (public member function) | |
| ビューが空かどうかをチェックする (public member function) | |
| (DR*) |
最初の文字にアクセスする ( std::basic_string<CharT,Traits,Allocator> の public メンバ関数) |