類模板
<regex>

std::sub_match

template <class BidirectionalIterator>class sub_match : public pair <BidirectionalIterator, BidirectionalIterator>;
子表示式匹配
儲存由 regex_matchregex_search 的正則表示式演算法,或由 正則表示式迭代器regex_iteratorregex_token_iterator)填充的 match_results 物件中的各個匹配項。這些匹配項是字元序列。但是此類物件本身並不儲存字元序列,而是派生自 pair,用於儲存指向序列的起始字元和 尾後 字元的 雙向迭代器 對,並提供對該序列的引用語義。

此類向從 pair 繼承的資料添加了一個公共成員變數,型別為

bool,名為matched。此成員儲存物件的狀態(“已匹配”或“未匹配”)。使用其預設建構函式構造的物件將把此成員設定為false,而作為 match_results 物件一部分的物件將把此成員設定為true。此類物件可以轉換為 string 物件(或相應的.

basic_string型別),並且在比較時表現得像字串物件。它們還有一個 length 成員,其行為類似於其 string 對應項。在此基本類中有四種例項化存在於標準標頭檔案中

對於最常見的情況<regex>BidirectionalIterator
1
2
3
4
typedef sub_match<const char*> csub_match;
typedef sub_match<const wchar_t*> wcsub_match;
typedef sub_match<string::const_iterator> ssub_match;
typedef sub_match<wstring::const_iterator> wssub_match;


模板引數

指向字元序列的 雙向迭代器型別
模板例項化

sub_match for string literals (class)


成員型別

以下別名是sub_match:

成員型別定義說明
iterator_traits<BidirectionalIterator>::value_type序列中字元的型別。string_type
basic_string<value_type>字元型別的 string 型別。iterator
模板引數指向字元序列的 雙向迭代器型別difference_type
iterator_traits<BidirectionalIterator>::size_typefirst_type相同,通常與 ptrdiff_t 一樣
pair 相同(繼承自 pair)。指向字元序列的 雙向迭代器型別(inherited from pair).模板引數second_type
Construct sub_match (public member function)指向字元序列的 雙向迭代器型別(inherited from pair).模板引數second_type

成員函式


swapfrom pair.