std::regex_traits
來自 cppreference.com
在標頭檔案 <regex> 中定義 |
||
template< class CharT > class regex_traits; |
(C++11 起) | |
型別特性模板 regex_traits
為 std::basic_regex 提供操作型別 CharT
所需的型別集和函式集。
由於許多正則表示式操作都是與區域設定相關的(當設定 std::regex_constants::collate 標誌時),regex_traits 類通常將 std::locale 例項作為私有成員持有。
[編輯] 標準特化
標準庫定義了 std::regex_traits
的兩個特化
std::regex_traits<char>
| |
std::regex_traits<wchar_t>
|
這些特化使得使用 std::basic_regex<char> (即 std::regex) 和 std::basic_regex<wchar_t> (即 std::wregex) 成為可能。要將 std::basic_regex 與其他字元型別(例如 char32_t)一起使用,必須使用使用者提供的特性類。
[編輯] 成員型別
型別 | 定義 |
char_type
|
CharT
|
string_type
|
std::basic_string<CharT> |
locale_type
|
用於正則表示式中本地化行為的區域設定。必須是 CopyConstructible |
char_class_type
|
表示字元分類,能夠儲存 lookup_classname 返回的實現特定集。必須是 BitmaskType。 |
[編輯] 成員函式
構造 regex_traits 物件 (public member function) | |
[靜態] |
計算以 null 結尾的字元字串的長度 (public static 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) |