名稱空間
變體
操作

std::experimental::basic_string_view

來自 cppreference.com
< cpp‎ | 實驗性
 
 
實驗性
技術規範
檔案系統庫 (檔案系統 TS)
庫基礎 (庫基礎 TS)
庫基礎 2 (庫基礎 TS v2)
庫基礎 3 (庫基礎 TS v3)
並行性擴充套件 (並行性 TS)
並行性擴充套件 2 (並行性 TS v2)
併發性擴充套件 (併發性 TS)
併發擴充套件 2 (concurrency TS v2)
概念 (概念 TS)
範圍 (範圍 TS)
反射 (反射 TS)
數學特殊函式 (特殊函式 TR)
實驗性非 TS
模式匹配
線性代數
std::execution
契約
2D 圖形
 
 
 
定義於標頭檔案 <experimental/string_view>
template<

    class CharT,
    class Traits = std::char_traits<CharT>

> class basic_string_view;
(庫基礎 TS)

類模板 basic_string_view 描述了一個物件,該物件可以引用一個常量連續的類字元物件序列,序列的第一個元素位於位置零。

典型的實現只包含兩個成員:一個指向常量 CharT 的指標和一個大小。

提供了用於常見字元型別的幾個 typedef

定義於標頭檔案 <experimental/string_view>
型別 定義
std::experimental::string_view std::experimental::basic_string_view<char>
std::experimental::wstring_view std::experimental::basic_string_view<wchar_t>
std::experimental::u16string_view std::experimental::basic_string_view<char16_t>
std::experimental::u32string_view std::experimental::basic_string_view<char32_t>

目錄

[編輯] 模板引數

CharT - 字元型別
特性 - 特性類,指定字元型別的操作

[編輯] 成員型別

成員型別 定義
traits_type 特性
value_type CharT
pointer CharT*
const_pointer const CharT*
reference CharT&
const_reference const CharT&
const_iterator 實現定義的 LegacyRandomAccessIterator
iterator const_iterator
reverse_iterator const_reverse_iterator
const_reverse_iterator std::reverse_iterator<const_iterator>
size_type std::size_t
difference_type std::ptrdiff_t

注意:iteratorconst_iterator 是同一型別,因為字串檢視是對常量字元序列的檢視。

[編輯] 成員函式

構造 basic_string_view
(public member function) [編輯]
賦值檢視
(public member function) [編輯]
迭代器
返回指向起始的迭代器
(public member function) [編輯]
返回指向末尾的迭代器
(public member function) [編輯]
返回指向起始的逆向迭代器
(public member function) [編輯]
返回指向末尾的逆向迭代器
(public member function) [編輯]
元素訪問
訪問指定的字元
(public member function) [編輯]
帶邊界檢查的訪問指定字元
(public member function) [編輯]
訪問第一個字元
(public member function) [編輯]
訪問最後一個字元
(public member function) [編輯]
返回指向檢視首字元的指標
(public member function) [編輯]
容量
返回字元數
(public member function) [編輯]
返回字元的最大數量
(public member function) [編輯]
檢查檢視是否為空
(public member function) [編輯]
修改器
透過前移其起始位置來收縮檢視
(public member function) [編輯]
通過後移其末尾位置來收縮檢視
(public member function) [編輯]
交換內容
(public member function) [編輯]
操作
從檢視建立字串
(public member function) [編輯]
複製字元
(public member function) [編輯]
返回子字串
(public member function) [編輯]
比較兩個檢視
(public member function) [編輯]
在檢視中查詢字元
(public member function) [編輯]
查詢子串的最後一次出現
(public member function) [編輯]
查詢字元的首次出現
(public member function) [編輯]
查詢字元的最後一次出現
(public member function) [編輯]
查詢字元的首次缺席
(public member function) [編輯]
查詢字元的最後一次缺席
(public member function) [編輯]

常量

[靜態]
特殊值。確切含義取決於上下文
(public static member constant) [編輯]

[編輯] 非成員函式

按字典序比較兩個檢視
(function template) [編輯]
輸入/輸出
對檢視執行流輸出
(function template) [編輯]

[編輯] 輔助類

對檢視的雜湊支援
(class template specialization) [編輯]

[編輯] 特性測試宏

__cpp_lib_experimental_string_view
值至少為 201411 表示支援 basic_string_view 模板
(宏常量)