Subclause | Header | ||
Primitive numeric conversions | <charconv> | ||
Localization library | <locale>, <clocale> | ||
Formatting | <format> | ||
Text encodings identification | <text_encoding> | ||
Regular expressions library | <regex> | ||
Null-terminated sequence utilities | <cctype>, <cstdlib>, <cuchar>, <cwchar>, <cwctype> |
constexpr to_chars_result to_chars(char* first, char* last, integer-type value, int base = 10);
to_chars_result to_chars(char* first, char* last, floating-point-type value);
to_chars_result to_chars(char* first, char* last, floating-point-type value, chars_format fmt);
to_chars_result to_chars(char* first, char* last, floating-point-type value,
chars_format fmt, int precision);
constexpr from_chars_result from_chars(const char* first, const char* last,
integer-type& value, int base = 10);
from_chars_result from_chars(const char* first, const char* last, floating-point-type& value,
chars_format fmt = chars_format::general);
Subclause | Header | ||
Locales | <locale> | ||
Standard locale categories | |||
C library locales | <clocale> | ||
using category = int;
Category | Includes facets | |
collate | collate<char>, collate<wchar_t> | |
ctype | ctype<char>, ctype<wchar_t> | |
codecvt<char, char, mbstate_t> | ||
codecvt<wchar_t, char, mbstate_t> | ||
monetary | moneypunct<char>, moneypunct<wchar_t> | |
moneypunct<char, true>, moneypunct<wchar_t, true> | ||
money_get<char>, money_get<wchar_t> | ||
money_put<char>, money_put<wchar_t> | ||
numeric | numpunct<char>, numpunct<wchar_t> | |
num_get<char>, num_get<wchar_t> | ||
num_put<char>, num_put<wchar_t> | ||
time | time_get<char>, time_get<wchar_t> | |
time_put<char>, time_put<wchar_t> | ||
messages | messages<char>, messages<wchar_t> |
Category | Includes facets | |
collate | collate_byname<char>, collate_byname<wchar_t> | |
ctype | ctype_byname<char>, ctype_byname<wchar_t> | |
codecvt_byname<char, char, mbstate_t> | ||
codecvt_byname<wchar_t, char, mbstate_t> | ||
monetary | moneypunct_byname<char, International> | |
moneypunct_byname<wchar_t, International> | ||
money_get<C, InputIterator> | ||
money_put<C, OutputIterator> | ||
numeric | numpunct_byname<char>, numpunct_byname<wchar_t> | |
num_get<C, InputIterator>, num_put<C, OutputIterator> | ||
time | time_get<char, InputIterator> | |
time_get_byname<char, InputIterator> | ||
time_get<wchar_t, InputIterator> | ||
time_get_byname<wchar_t, InputIterator> | ||
time_put<char, OutputIterator> | ||
time_put_byname<char, OutputIterator> | ||
time_put<wchar_t, OutputIterator> | ||
time_put_byname<wchar_t, OutputIterator> | ||
messages | messages_byname<char>, messages_byname<wchar_t> |
locale() noexcept;
explicit locale(const char* std_name);
explicit locale(const string& std_name);
locale(const locale& other, const char* std_name, category cats);
locale(const locale& other, const string& std_name, category cats);
template<class Facet> locale(const locale& other, Facet* f);
locale(const locale& other, const locale& one, category cats);
const locale& operator=(const locale& other) noexcept;
template<class Facet> locale combine(const locale& other) const;
string name() const;
text_encoding encoding() const;
bool operator==(const locale& other) const;
template<class charT, class traits, class Allocator>
bool operator()(const basic_string<charT, traits, Allocator>& s1,
const basic_string<charT, traits, Allocator>& s2) const;
static locale global(const locale& loc);
static const locale& classic();
template<class Facet> const Facet& use_facet(const locale& loc);
template<class Facet> bool has_facet(const locale& loc) noexcept;
template<class charT> bool isspace (charT c, const locale& loc);
template<class charT> bool isprint (charT c, const locale& loc);
template<class charT> bool iscntrl (charT c, const locale& loc);
template<class charT> bool isupper (charT c, const locale& loc);
template<class charT> bool islower (charT c, const locale& loc);
template<class charT> bool isalpha (charT c, const locale& loc);
template<class charT> bool isdigit (charT c, const locale& loc);
template<class charT> bool ispunct (charT c, const locale& loc);
template<class charT> bool isxdigit(charT c, const locale& loc);
template<class charT> bool isalnum (charT c, const locale& loc);
template<class charT> bool isgraph (charT c, const locale& loc);
template<class charT> bool isblank (charT c, const locale& loc);
template<class charT> charT toupper(charT c, const locale& loc);
template<class charT> charT tolower(charT c, const locale& loc);
bool is(mask m, charT c) const;
const charT* is(const charT* low, const charT* high, mask* vec) const;
const charT* scan_is(mask m, const charT* low, const charT* high) const;
const charT* scan_not(mask m, const charT* low, const charT* high) const;
charT toupper(charT c) const;
const charT* toupper(charT* low, const charT* high) const;
charT tolower(charT c) const;
const charT* tolower(charT* low, const charT* high) const;
charT widen(char c) const;
const char* widen(const char* low, const char* high, charT* to) const;
char narrow(charT c, char dfault) const;
const charT* narrow(const charT* low, const charT* high, char dfault, char* to) const;
bool do_is(mask m, charT c) const;
const charT* do_is(const charT* low, const charT* high, mask* vec) const;
const charT* do_scan_is(mask m, const charT* low, const charT* high) const;
const charT* do_scan_not(mask m, const charT* low, const charT* high) const;
charT do_toupper(charT c) const;
const charT* do_toupper(charT* low, const charT* high) const;
charT do_tolower(charT c) const;
const charT* do_tolower(charT* low, const charT* high) const;
charT do_widen(char c) const;
const char* do_widen(const char* low, const char* high, charT* dest) const;
char do_narrow(charT c, char dfault) const;
const charT* do_narrow(const charT* low, const charT* high, char dfault, char* dest) const;
~ctype();
explicit ctype(const mask* tbl = nullptr, bool del = false, size_t refs = 0);
bool is(mask m, char c) const;
const char* is(const char* low, const char* high, mask* vec) const;
const char* scan_is(mask m, const char* low, const char* high) const;
const char* scan_not(mask m, const char* low, const char* high) const;
char toupper(char c) const;
const char* toupper(char* low, const char* high) const;
char tolower(char c) const;
const char* tolower(char* low, const char* high) const;
char widen(char c) const;
const char* widen(const char* low, const char* high, char* to) const;
char narrow(char c, char dfault) const;
const char* narrow(const char* low, const char* high, char dfault, char* to) const;
const mask* table() const noexcept;
static const mask* classic_table() noexcept;
result out(
stateT& state,
const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_end, externT*& to_next) const;
result unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;
result in(
stateT& state,
const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_end, internT*& to_next) const;
int encoding() const noexcept;
bool always_noconv() const noexcept;
int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
int max_length() const noexcept;
result do_out(
stateT& state,
const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_end, externT*& to_next) const;
result do_in(
stateT& state,
const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_end, internT*& to_next) const;
Value | Meaning | |
ok | completed the conversion | |
partial | not all source characters converted | |
error | encountered a character in [from, from_end)
that cannot be converted | |
noconv | internT and externT are the same type, and input
sequence is identical to converted sequence |
result do_unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;
Value | Meaning | |
ok | completed the sequence | |
partial | space for more than to_end - to destination elements was needed
to terminate a sequence given the value of state | |
error | an unspecified error has occurred | |
noconv | no termination is needed for this state_type |
int do_encoding() const noexcept;
bool do_always_noconv() const noexcept;
int do_length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
int do_max_length() const noexcept;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, bool& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long long& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned short& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned int& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned long& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned long long& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, float& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, double& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long double& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, void*& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long long& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned short& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned int& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned long& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned long long& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, float& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, double& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long double& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, void*& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, bool& val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, bool val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, long val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, long long val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, unsigned long long val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, double val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, long double val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, const void* val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, long val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, long long val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long long val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, double val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, long double val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, const void* val) const;
State | stdio equivalent | |
floatfield == ios_base::fixed | %f | |
floatfield == ios_base::scientific && !uppercase | %e | |
floatfield == ios_base::scientific | %E | |
floatfield == (ios_base::fixed | ios_base::scientific) && !uppercase | %a | |
floatfield == (ios_base::fixed | ios_base::scientific) | %A | |
!uppercase | %g | |
otherwise | %G |
State | Location | |
adjustfield == ios_base::left | pad after | |
adjustfield == ios_base::right | pad before | |
adjustfield == internal and a sign occurs in the representation | pad after the sign | |
adjustfield == internal and representation after stage 1
began with 0x or 0X | pad after x or X | |
otherwise | pad before |
iter_type do_put(iter_type out, ios_base& str, char_type fill, bool val) const;
char_type decimal_point() const;
char_type thousands_sep() const;
string grouping() const;
string_type truename() const;
string_type falsename() const;
char_type do_decimal_point() const;
char_type do_thousands_sep() const;
string do_grouping() const;
string_type do_truename() const;
string_type do_falsename() const;
int compare(const charT* low1, const charT* high1,
const charT* low2, const charT* high2) const;
string_type transform(const charT* low, const charT* high) const;
long hash(const charT* low, const charT* high) const;
int do_compare(const charT* low1, const charT* high1,
const charT* low2, const charT* high2) const;
string_type do_transform(const charT* low, const charT* high) const;
long do_hash(const charT* low, const charT* high) const;
dateorder date_order() const;
iter_type get_time(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type get_date(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type get_weekday(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type get_monthname(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type get_year(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err,
tm* t, char format, char modifier = 0) const;
iter_type get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err,
tm* t, const char_type* fmt, const char_type* fmtend) const;
dateorder do_date_order() const;
iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type do_get_weekday(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type do_get_monthname(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type do_get_year(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type do_get(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t, char format, char modifier) const;
iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
const charT* pattern, const charT* pat_end) const;
iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
char format, char modifier = 0) const;
iter_type do_put(iter_type s, ios_base&, char_type fill, const tm* t,
char format, char modifier) const;
iter_type get(iter_type s, iter_type end, bool intl, ios_base& f,
ios_base::iostate& err, long double& quant) const;
iter_type get(iter_type s, iter_type end, bool intl, ios_base& f,
ios_base::iostate& err, string_type& quant) const;
iter_type do_get(iter_type s, iter_type end, bool intl, ios_base& str,
ios_base::iostate& err, long double& units) const;
iter_type do_get(iter_type s, iter_type end, bool intl, ios_base& str,
ios_base::iostate& err, string_type& digits) const;
iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, long double quant) const;
iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, const string_type& quant) const;
iter_type do_put(iter_type s, bool intl, ios_base& str,
char_type fill, long double units) const;
iter_type do_put(iter_type s, bool intl, ios_base& str,
char_type fill, const string_type& digits) const;
charT do_decimal_point() const;
charT do_thousands_sep() const;
string do_grouping() const;
string_type do_curr_symbol() const;
string_type do_positive_sign() const;
string_type do_negative_sign() const;
int do_frac_digits() const;
pattern do_pos_format() const;
pattern do_neg_format() const;
catalog open(const string& name, const locale& loc) const;
string_type get(catalog cat, int set, int msgid, const string_type& dfault) const;
void close(catalog cat) const;
catalog do_open(const string& name, const locale& loc) const;
string_type do_get(catalog cat, int set, int msgid, const string_type& dfault) const;
void do_close(catalog cat) const;
fprintf | isprint | iswdigit | localeconv | tolower | |
fscanf | ispunct | iswgraph | mblen | toupper | |
isalnum | isspace | iswlower | mbstowcs | towlower | |
isalpha | isupper | iswprint | mbtowc | towupper | |
isblank | iswalnum | iswpunct | setlocale | wcscoll | |
iscntrl | iswalpha | iswspace | strcoll | wcstod | |
isdigit | iswblank | iswupper | strerror | wcstombs | |
isgraph | iswcntrl | iswxdigit | strtod | wcsxfrm | |
islower | iswctype | isxdigit | strxfrm | wctomb |
constexpr explicit text_encoding(string_view enc) noexcept;
constexpr text_encoding(id i) noexcept;
constexpr id mib() const noexcept;
constexpr const char* name() const noexcept;
constexpr aliases_view aliases() const noexcept;
static consteval text_encoding literal() noexcept;
static text_encoding environment();
template<id i>
static bool environment_is();
static constexpr bool comp-name(string_view a, string_view b);
friend constexpr bool operator==(const text_encoding& a, const text_encoding& b) noexcept;
friend constexpr bool operator==(const text_encoding& encoding, id i) noexcept;
template<> struct hash<text_encoding>;
Option | Meaning | |
< | ||
> | ||
^ | Forces the formatted argument to be centered within the field
by inserting
fill characters before and
fill characters after the formatted argument, where
n is the padding width. |
Option | Meaning | |
+ | ||
- | Indicates that a sign should be used for
negative numbers and negative zero only (this is the default behavior). | |
space | Indicates that a leading space should be used for
non-negative numbers other than negative zero, and
a minus sign for negative numbers and negative zero. |
Type | Meaning | |
none, s | Copies the string to the output. | |
? | Copies the escaped string ([format.string.escaped]) to the output. |
Type | Meaning | |
b | ||
B | ||
c | ||
d | to_chars(first, last, value). | |
o | ||
x | ||
X | ||
none |
Type | Meaning | |
none, c | Copies the character to the output. | |
b, B, d, o, x, X | ||
? | Copies the escaped character ([format.string.escaped]) to the output. |
Type | Meaning | |
a | If precision is specified, equivalent to
to_chars(first, last, value, chars_format::hex, precision)
where precision is the specified formatting precision; equivalent to
to_chars(first, last, value, chars_format::hex)
otherwise. | |
A | The same as a, except that
it uses uppercase letters for digits above 9 and
P to indicate the exponent. | |
e | Equivalent to
to_chars(first, last, value, chars_format::scientific, precision)
where precision is the specified formatting precision,
or 6 if precision is not specified. | |
E | ||
f, F | Equivalent to
to_chars(first, last, value, chars_format::fixed, precision)
where precision is the specified formatting precision,
or 6 if precision is not specified. | |
g | Equivalent to
to_chars(first, last, value, chars_format::general, precision)
where precision is the specified formatting precision,
or 6 if precision is not specified. | |
G | ||
none | If precision is specified, equivalent to
to_chars(first, last, value, chars_format::general, precision)
where precision is the specified formatting precision; equivalent to
to_chars(first, last, value)
otherwise. |
Type | Meaning | |
none, p | If uintptr_t is defined,
to_chars(first, last, reinterpret_cast<uintptr_t>(value), 16)
with the prefix 0x inserted immediately before the output of to_chars;
otherwise, implementation-defined. | |
P |
template<class T> consteval basic_format_string(const T& s);
template<class... Args>
string format(format_string<Args...> fmt, Args&&... args);
template<class... Args>
wstring format(wformat_string<Args...> fmt, Args&&... args);
template<class... Args>
string format(const locale& loc, format_string<Args...> fmt, Args&&... args);
template<class... Args>
wstring format(const locale& loc, wformat_string<Args...> fmt, Args&&... args);
string vformat(string_view fmt, format_args args);
wstring vformat(wstring_view fmt, wformat_args args);
string vformat(const locale& loc, string_view fmt, format_args args);
wstring vformat(const locale& loc, wstring_view fmt, wformat_args args);
template<class Out, class... Args>
Out format_to(Out out, format_string<Args...> fmt, Args&&... args);
template<class Out, class... Args>
Out format_to(Out out, wformat_string<Args...> fmt, Args&&... args);
template<class Out, class... Args>
Out format_to(Out out, const locale& loc, format_string<Args...> fmt, Args&&... args);
template<class Out, class... Args>
Out format_to(Out out, const locale& loc, wformat_string<Args...> fmt, Args&&... args);
template<class Out>
Out vformat_to(Out out, string_view fmt, format_args args);
template<class Out>
Out vformat_to(Out out, wstring_view fmt, wformat_args args);
template<class Out>
Out vformat_to(Out out, const locale& loc, string_view fmt, format_args args);
template<class Out>
Out vformat_to(Out out, const locale& loc, wstring_view fmt, wformat_args args);
template<class Out, class... Args>
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
format_string<Args...> fmt, Args&&... args);
template<class Out, class... Args>
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
wformat_string<Args...> fmt, Args&&... args);
template<class Out, class... Args>
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
const locale& loc, format_string<Args...> fmt,
Args&&... args);
template<class Out, class... Args>
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
const locale& loc, wformat_string<Args...> fmt,
Args&&... args);
template<class... Args>
size_t formatted_size(format_string<Args...> fmt, Args&&... args);
template<class... Args>
size_t formatted_size(wformat_string<Args...> fmt, Args&&... args);
template<class... Args>
size_t formatted_size(const locale& loc, format_string<Args...> fmt, Args&&... args);
template<class... Args>
size_t formatted_size(const locale& loc, wformat_string<Args...> fmt, Args&&... args);
Expression | Return type | Requirement | |
g.parse(pc) | PC::iterator | Parses format-spec ([format.string])
for type T
in the range [pc.begin(), pc.end())
until the first unmatched character.
Stores the parsed format specifiers in *this and
returns an iterator past the end of the parsed range. | |
f.format(u, fc) | FC::iterator | Formats u according to the specifiers stored in *this,
writes the output to fc.out(), and
returns an iterator past the end of the output range. The output shall only depend on
u,
fc.locale(),
fc.arg(n) for any value n of type size_t,
and the range [pc.begin(), pc.end())
from the last call to f.parse(pc). |
Expression | Return type | Requirement | |
f.format(t, fc) | FC::iterator | Formats t according to the specifiers stored in *this,
writes the output to fc.out(), and
returns an iterator past the end of the output range. The output shall only depend on
t,
fc.locale(),
fc.arg(n) for any value n of type size_t,
and the range [pc.begin(), pc.end())
from the last call to f.parse(pc). | |
f.format(u, fc) | FC::iterator | As above, but does not modify u. |
template<class T>
constexpr bool enable_nonlocking_formatter_optimization = false;
constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt) noexcept;
constexpr const_iterator begin() const noexcept;
constexpr const_iterator end() const noexcept;
constexpr void advance_to(const_iterator it);
constexpr size_t next_arg_id();
constexpr void check_arg_id(size_t id);
template<class... Ts>
constexpr void check_dynamic_spec(size_t id) noexcept;
constexpr void check_dynamic_spec_integral(size_t id) noexcept;
constexpr void check_dynamic_spec_string(size_t id) noexcept;
basic_format_arg<basic_format_context> arg(size_t id) const noexcept;
std::locale locale();
iterator out();
void advance_to(iterator it);
template<ranges::input_range R>
requires same_as<R, remove_cvref_t<R>>
constexpr range_format format_kind<R> = see below;
Option | Requirements | Meaning | |
m | T shall be
either a specialization of pair or a specialization of tuple
such that tuple_size_v<T> is 2. | Indicates that
the opening bracket should be "{",
the closing bracket should be "}",
the separator should be ", ", and
each range element should be formatted as if
m were specified for its tuple-type. | |
s | Indicates that the range should be formatted as a string. | ||
?s | Indicates that the range should be formatted as
an escaped string ([format.string.escaped]). |
constexpr void set_separator(basic_string_view<charT> sep) noexcept;
constexpr void set_brackets(basic_string_view<charT> opening,
basic_string_view<charT> closing) noexcept;
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<ranges::input_range R, class FormatContext>
requires formattable<ranges::range_reference_t<R>, charT> &&
same_as<remove_cvref_t<ranges::range_reference_t<R>>, T>
typename FormatContext::iterator
format(R&& r, FormatContext& ctx) const;
constexpr void set_separator(basic_string_view<charT> sep) noexcept;
constexpr void set_brackets(basic_string_view<charT> opening,
basic_string_view<charT> closing) noexcept;
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<class FormatContext>
typename FormatContext::iterator
format(maybe-const-r& elems, FormatContext& ctx) const;
constexpr range-default-formatter();
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<class FormatContext>
typename FormatContext::iterator
format(maybe-const-map& r, FormatContext& ctx) const;
constexpr range-default-formatter();
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<class FormatContext>
typename FormatContext::iterator
format(maybe-const-set& r, FormatContext& ctx) const;
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<class FormatContext>
typename FormatContext::iterator
format(see below& r, FormatContext& ctx) const;
basic_format_arg() noexcept;
template<class T> explicit basic_format_arg(T& v) noexcept;
explicit operator bool() const noexcept;
template<class Visitor>
decltype(auto) visit(this basic_format_arg arg, Visitor&& vis);
template<class R, class Visitor>
R visit(this basic_format_arg arg, Visitor&& vis);
template<class T> explicit handle(T& val) noexcept;
void format(basic_format_parse_context<char_type>& parse_ctx, Context& format_ctx) const;
template<class Context = format_context, class... Args>
format-arg-store<Context, Args...> make_format_args(Args&... fmt_args);
template<class... Args>
format-arg-store<wformat_context, Args...> make_wformat_args(Args&... args);
template<class... Args>
basic_format_args(const format-arg-store<Context, Args...>& store) noexcept;
basic_format_arg<Context> get(size_t i) const noexcept;
constexpr void set_separator(basic_string_view<charT> sep) noexcept;
constexpr void set_brackets(basic_string_view<charT> opening,
basic_string_view<charT> closing) noexcept;
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<class FormatContext>
typename FormatContext::iterator
format(see below& elems, FormatContext& ctx) const;
format_error(const string& what_arg);
format_error(const char* what_arg);
Subclause | Header | ||
Requirements | |||
Constants | <regex> | ||
Exception type | |||
Traits | |||
Regular expression template | |||
Submatches | |||
Match results | |||
Algorithms | |||
Iterators | |||
Grammar |
typename X::char_type
typename X::string_type
typename X::locale_type
typename X::char_class_type
X::length(p)
v.translate(c)
v.translate_nocase(c)
v.transform(F1, F2)
v.transform_primary(F1, F2)
v.lookup_collatename(F1, F2)
v.lookup_classname(F1, F2, b)
v.isctype(c, cl)
v.value(c, I)
u.imbue(loc)
v.getloc()
Element | Effect(s) if set | |
icase | Specifies that matching of regular expressions against a character
container sequence shall be performed without regard to case. | |
nosubs | Specifies that no sub-expressions shall be considered to be marked, so that
when a regular expression is matched against a
character container sequence, no sub-expression matches shall be
stored in the supplied match_results object. | |
optimize | ||
collate | ||
ECMAScript | Specifies that the grammar recognized by the regular expression engine
shall be that used by ECMAScript in ECMA-262, as modified in [re.grammar]. | |
basic | Specifies that the grammar recognized by the regular expression engine
shall be that used by basic regular expressions in POSIX. See also: POSIX, Base Definitions and Headers, Section 9.3 | |
extended | Specifies that the grammar recognized by the regular expression engine
shall be that used by extended regular expressions in POSIX. See also: POSIX, Base Definitions and Headers, Section 9.4 | |
awk | Specifies that the grammar recognized by the regular expression engine
shall be that used by the utility awk in POSIX. | |
grep | Specifies that the grammar recognized by the regular expression engine
shall be that used by the utility grep in POSIX. | |
egrep | Specifies that the grammar recognized by the regular expression engine
shall be that used by the utility grep when given the -E
option in POSIX. | |
multiline | Specifies that ^ shall match the beginning of a line and
$ shall match the end of a line,
if the ECMAScript engine is selected. |
Element | Effect(s) if set | |
The first character in the sequence [first, last) shall be treated
as though it is not at the beginning of a line, so the character
^ in the regular expression shall not match [first, first). | ||
The last character in the sequence [first, last) shall be treated
as though it is not at the end of a line, so the character
"$" in the regular expression shall not match [last, last). | ||
If more than one match is possible then any match is an
acceptable result. | ||
The expression shall not match an empty
sequence. | ||
The expression shall only match a sub-sequence that begins at
first. | ||
When a regular expression match is to be replaced by a
new string, the new string shall be constructed using the rules used by
the ECMAScript replace function in ECMA-262,
part 15.5.4.11 String.prototype.replace. In
addition, during search and replace operations all non-overlapping
occurrences of the regular expression shall be located and replaced, and
sections of the input that did not match the expression shall be copied
unchanged to the output string. | ||
When a regular expression match is to be replaced by a
new string, the new string shall be constructed using the rules used by
the sed utility in POSIX. | ||
During a search and replace operation, sections of
the character container sequence being searched that do not match the
regular expression shall not be copied to the output string. | ||
When specified during a search and replace operation, only the
first occurrence of the regular expression shall be replaced. |
Value | Error condition | |
error_collate | The expression contains an invalid collating element name. | |
error_ctype | The expression contains an invalid character class name. | |
error_escape | The expression contains an invalid escaped character, or a trailing
escape. | |
error_backref | The expression contains an invalid back reference. | |
error_brack | ||
error_paren | ||
error_brace | The expression contains mismatched { and } | |
error_badbrace | The expression contains an invalid range in a {} expression. | |
error_range | The expression contains an invalid character range, such as
[b-a] in most encodings. | |
error_space | There is insufficient memory to convert the expression into a finite
state machine. | |
error_badrepeat | One of *?+{ is not preceded by a valid regular expression. | |
error_complexity | The complexity of an attempted match against a regular expression
exceeds a pre-set level. | |
error_stack | There is insufficient memory to determine whether the regular
expression matches the specified character sequence. |
regex_error(regex_constants::error_type ecode);
regex_constants::error_type code() const;
using char_class_type = bitmask_type;
static size_t length(const char_type* p);
charT translate(charT c) const;
charT translate_nocase(charT c) const;
template<class ForwardIterator>
string_type transform(ForwardIterator first, ForwardIterator last) const;
template<class ForwardIterator>
string_type transform_primary(ForwardIterator first, ForwardIterator last) const;
template<class ForwardIterator>
string_type lookup_collatename(ForwardIterator first, ForwardIterator last) const;
template<class ForwardIterator>
char_class_type lookup_classname(
ForwardIterator first, ForwardIterator last, bool icase = false) const;
bool isctype(charT c, char_class_type f) const;
int value(charT ch, int radix) const;
locale_type imbue(locale_type loc);
locale_type getloc() const;
Narrow character name | Wide character name | Corresponding ctype_base::mask value | |
"alnum" | L"alnum" | ctype_base::alnum | |
"alpha" | L"alpha" | ctype_base::alpha | |
"blank" | L"blank" | ctype_base::blank | |
"cntrl" | L"cntrl" | ctype_base::cntrl | |
"digit" | L"digit" | ctype_base::digit | |
"d" | L"d" | ctype_base::digit | |
"graph" | L"graph" | ctype_base::graph | |
"lower" | L"lower" | ctype_base::lower | |
"print" | L"print" | ctype_base::print | |
"punct" | L"punct" | ctype_base::punct | |
"space" | L"space" | ctype_base::space | |
"s" | L"s" | ctype_base::space | |
"upper" | L"upper" | ctype_base::upper | |
"w" | L"w" | ctype_base::alnum | |
"xdigit" | L"xdigit" | ctype_base::xdigit |
basic_regex();
explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
basic_regex(const basic_regex& e);
basic_regex(basic_regex&& e) noexcept;
template<class ST, class SA>
explicit basic_regex(const basic_string<charT, ST, SA>& s,
flag_type f = regex_constants::ECMAScript);
template<class ForwardIterator>
basic_regex(ForwardIterator first, ForwardIterator last,
flag_type f = regex_constants::ECMAScript);
basic_regex(initializer_list<charT> il, flag_type f = regex_constants::ECMAScript);
basic_regex& operator=(const basic_regex& e);
basic_regex& operator=(basic_regex&& e) noexcept;
basic_regex& operator=(const charT* p);
basic_regex& operator=(initializer_list<charT> il);
template<class ST, class SA>
basic_regex& operator=(const basic_string<charT, ST, SA>& s);
basic_regex& assign(const basic_regex& e);
basic_regex& assign(basic_regex&& e) noexcept;
basic_regex& assign(const charT* p, flag_type f = regex_constants::ECMAScript);
basic_regex& assign(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
template<class ST, class SA>
basic_regex& assign(const basic_string<charT, ST, SA>& s,
flag_type f = regex_constants::ECMAScript);
template<class InputIterator>
basic_regex& assign(InputIterator first, InputIterator last,
flag_type f = regex_constants::ECMAScript);
basic_regex& assign(initializer_list<charT> il,
flag_type f = regex_constants::ECMAScript);
unsigned mark_count() const;
flag_type flags() const;
constexpr sub_match();
difference_type length() const;
operator string_type() const;
string_type str() const;
int compare(const sub_match& s) const;
int compare(const string_type& s) const;
int compare(const value_type* s) const;
void swap(sub_match& s) noexcept(see below);
template<class BiIter>
bool operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
template<class BiIter>
auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
template<class BiIter, class ST, class SA>
bool operator==(
const sub_match<BiIter>& lhs,
const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
template<class BiIter, class ST, class SA>
auto operator<=>(
const sub_match<BiIter>& lhs,
const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
template<class BiIter>
bool operator==(const sub_match<BiIter>& lhs,
const typename iterator_traits<BiIter>::value_type* rhs);
template<class BiIter>
auto operator<=>(const sub_match<BiIter>& lhs,
const typename iterator_traits<BiIter>::value_type* rhs);
template<class BiIter>
bool operator==(const sub_match<BiIter>& lhs,
const typename iterator_traits<BiIter>::value_type& rhs);
template<class BiIter>
auto operator<=>(const sub_match<BiIter>& lhs,
const typename iterator_traits<BiIter>::value_type& rhs);
template<class charT, class ST, class BiIter>
basic_ostream<charT, ST>&
operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
explicit match_results(const Allocator& a);
match_results(const match_results& m);
match_results(const match_results& m, const Allocator& a);
match_results(match_results&& m) noexcept;
match_results(match_results&& m, const Allocator& a);
match_results& operator=(const match_results& m);
match_results& operator=(match_results&& m);
Element | Value | |
ready() | m.ready() | |
size() | m.size() | |
str(n) | m.str(n) for all non-negative integers n < m.size() | |
prefix() | m.prefix() | |
suffix() | m.suffix() | |
(*this)[n] | m[n] for all non-negative integers n < m.size() | |
length(n) | m.length(n) for all non-negative integers n < m.size() | |
position(n) | m.position(n) for all non-negative integers n < m.size() |
bool ready() const;
size_type size() const;
size_type max_size() const;
bool empty() const;
difference_type length(size_type sub = 0) const;
difference_type position(size_type sub = 0) const;
string_type str(size_type sub = 0) const;
const_reference operator[](size_type n) const;
const_reference prefix() const;
const_reference suffix() const;
const_iterator begin() const;
const_iterator cbegin() const;
const_iterator end() const;
const_iterator cend() const;
template<class OutputIter>
OutputIter format(
OutputIter out,
const char_type* fmt_first, const char_type* fmt_last,
regex_constants::match_flag_type flags = regex_constants::format_default) const;
template<class OutputIter, class ST, class SA>
OutputIter format(
OutputIter out,
const basic_string<char_type, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::format_default) const;
template<class ST, class SA>
basic_string<char_type, ST, SA> format(
const basic_string<char_type, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::format_default) const;
string_type format(
const char_type* fmt,
regex_constants::match_flag_type flags = regex_constants::format_default) const;
allocator_type get_allocator() const;
void swap(match_results& that);
template<class BidirectionalIterator, class Allocator>
void swap(match_results<BidirectionalIterator, Allocator>& m1,
match_results<BidirectionalIterator, Allocator>& m2);
template<class BidirectionalIterator, class Allocator>
bool operator==(const match_results<BidirectionalIterator, Allocator>& m1,
const match_results<BidirectionalIterator, Allocator>& m2);
template<class BidirectionalIterator, class Allocator, class charT, class traits>
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
match_results<BidirectionalIterator, Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
Element | Value | |
m.size() | 1 + e.mark_count() | |
m.empty() | false | |
m.prefix().first | first | |
m.prefix().second | first | |
m.prefix().matched | false | |
m.suffix().first | last | |
m.suffix().second | last | |
m.suffix().matched | false | |
m[0].first | first | |
m[0].second | last | |
m[0].matched | true | |
m[n].first | ||
m[n].second | ||
m[n].matched | For all integers 0 < n < m.size(), true if sub-expression n participated in
the match, false otherwise. |
template<class BidirectionalIterator, class charT, class traits>
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class charT, class Allocator, class traits>
bool regex_match(const charT* str,
match_results<const charT*, Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class ST, class SA, class Allocator, class charT, class traits>
bool regex_match(const basic_string<charT, ST, SA>& s,
match_results<typename basic_string<charT, ST, SA>::const_iterator,
Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class charT, class traits>
bool regex_match(const charT* str,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class ST, class SA, class charT, class traits>
bool regex_match(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class BidirectionalIterator, class Allocator, class charT, class traits>
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
match_results<BidirectionalIterator, Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
Element | Value | |
m.size() | 1 + e.mark_count() | |
m.empty() | false | |
m.prefix().first | first | |
m.prefix().second | m[0].first | |
m.prefix().matched | m.prefix().first != m.prefix().second | |
m.suffix().first | m[0].second | |
m.suffix().second | last | |
m.suffix().matched | m.suffix().first != m.suffix().second | |
m[0].first | The start of the sequence of characters that matched the regular expression | |
m[0].second | The end of the sequence of characters that matched the regular expression | |
m[0].matched | true | |
m[n].first | ||
m[n].second | ||
m[n].matched | For all integers 0 < n < m.size(), true if sub-expression n
participated in the match, false otherwise. |
template<class charT, class Allocator, class traits>
bool regex_search(const charT* str, match_results<const charT*, Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class ST, class SA, class Allocator, class charT, class traits>
bool regex_search(const basic_string<charT, ST, SA>& s,
match_results<typename basic_string<charT, ST, SA>::const_iterator,
Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class BidirectionalIterator, class charT, class traits>
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class charT, class traits>
bool regex_search(const charT* str,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class ST, class SA, class charT, class traits>
bool regex_search(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class OutputIterator, class BidirectionalIterator,
class traits, class charT, class ST, class SA>
OutputIterator
regex_replace(OutputIterator out,
BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
const basic_string<charT, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class OutputIterator, class BidirectionalIterator, class traits, class charT>
OutputIterator
regex_replace(OutputIterator out,
BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class traits, class charT, class ST, class SA, class FST, class FSA>
basic_string<charT, ST, SA>
regex_replace(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
const basic_string<charT, FST, FSA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class traits, class charT, class ST, class SA>
basic_string<charT, ST, SA>
regex_replace(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class traits, class charT, class ST, class SA>
basic_string<charT>
regex_replace(const charT* s,
const basic_regex<charT, traits>& e,
const basic_string<charT, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class traits, class charT>
basic_string<charT>
regex_replace(const charT* s,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
regex_iterator();
regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
regex_constants::match_flag_type m = regex_constants::match_default);
bool operator==(const regex_iterator& right) const;
const value_type& operator*() const;
const value_type* operator->() const;
regex_iterator& operator++();
regex_iterator operator++(int);
regex_token_iterator();
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
int submatch = 0,
regex_constants::match_flag_type m = regex_constants::match_default);
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
const vector<int>& submatches,
regex_constants::match_flag_type m = regex_constants::match_default);
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
initializer_list<int> submatches,
regex_constants::match_flag_type m = regex_constants::match_default);
template<size_t N>
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
const int (&submatches)[N],
regex_constants::match_flag_type m = regex_constants::match_default);
bool operator==(const regex_token_iterator& right) const;
const value_type& operator*() const;
const value_type* operator->() const;
regex_token_iterator& operator++();
regex_token_iterator& operator++(int);
int mbsinit(const mbstate_t* ps);
int mblen(const char* s, size_t n);
size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n);
int mbtowc(wchar_t* pwc, const char* s, size_t n);
int wctomb(char* s, wchar_t wchar);
size_t mbrlen(const char* s, size_t n, mbstate_t* ps);
size_t mbrtowc(wchar_t* pwc, const char* s, size_t n, mbstate_t* ps);
size_t wcrtomb(char* s, wchar_t wc, mbstate_t* ps);
size_t mbsrtowcs(wchar_t* dst, const char** src, size_t len, mbstate_t* ps);
size_t wcsrtombs(char* dst, const wchar_t** src, size_t len, mbstate_t* ps);
size_t mbrtoc8(char8_t* pc8, const char* s, size_t n, mbstate_t* ps);
size_t c8rtomb(char* s, char8_t c8, mbstate_t* ps);