std::regex_traits::length - cppreference.com (original) (raw)
From cppreference.com
< cpp | regex | regex traits
| Localization library |
|---|
| Regular expressions library (C++11) |
| Formatting library (C++20) |
| Null-terminated sequence utilities |
| Byte strings |
| Multibyte strings |
| Wide strings |
| Primitive numeric conversions |
| to_chars(C++17) to_chars_result(C++17) from_chars(C++17) from_chars_result(C++17) chars_format(C++17) |
| Text encoding identifications |
| text_encoding(C++26) |
| Classes |
|---|
| basic_regex(C++11) |
| sub_match(C++11) |
| match_results(C++11) |
| Algorithms |
| regex_match(C++11) |
| regex_search(C++11) |
| regex_replace(C++11) |
| Iterators |
| regex_iterator(C++11) |
| regex_token_iterator(C++11) |
| Exceptions |
| regex_error(C++11) |
| Traits |
| regex_traits(C++11) |
| Constants |
| syntax_option_type(C++11) |
| match_flag_type(C++11) |
| error_type(C++11) |
| Regex Grammar |
| Modified ECMAScript-262(C++11) |
| static std::size_t length( const char_type* p ); | | | | -------------------------------------------------------------------------------- | | |
Calculates the length of a null-terminated character sequence, that is, the smallest i such that p[i] == 0.
Standard library specializations of std::regex_traits execute std::char_traits<CharT>::length(p);.
[edit] Parameters
| p | - | pointer to the first element of the null-terminated character sequence |
|---|
[edit] Return value
The length of the null-terminated character string.
[edit] Example
Run this code
#include #include int main() { std::cout << std::regex_traits::length("Кошка") << '\n' << std::regex_traits::length(L"Кошка") << '\n'; }
Output:
10 5
Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/regex/regex_traits/length&oldid=161050"