public member function
<regex>

std::regex_traits::length

static size_t length (const char_type* p);
返回字串的長度
返回由p指向的以 null 結尾的字元序列表示的字串的長度。

在語義上類似於 strlen C 函式。

regex_traits 中,它被定義為 char_traits 中同名函式的別名
1
2
3
static size_t length (const char_type* p) {
  return char_traits<char_type>::length(p);
}

引數

p
指向以 null 結尾的字元序列中第一個字元的指標。

返回值

傳遞的引數所指向的以 null 結尾的字元序列中的字元數(直到終止 null 字元,但不包括它)。
char_type是一個成員型別,定義為 regex_traits 的模板引數的別名(charT).

另見