mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 12:14:26 +00:00
Clarify that compile-time checks don't support named arguments
This commit is contained in:
parent
4f6fda558c
commit
06c005b7b0
@ -56,6 +56,8 @@ Named arguments
|
||||
|
||||
.. doxygenfunction:: fmt::arg(string_view, const T&)
|
||||
|
||||
Named arguments are not supported in compile-time checks at the moment.
|
||||
|
||||
Argument lists
|
||||
--------------
|
||||
|
||||
@ -92,6 +94,7 @@ string checks, output iterator and user-defined type support.
|
||||
Compile-time format string checks
|
||||
---------------------------------
|
||||
|
||||
.. doxygendefine:: FMT_STRING
|
||||
.. doxygendefine:: fmt
|
||||
|
||||
Formatting user-defined types
|
||||
|
@ -2117,7 +2117,9 @@ class format_string_checker {
|
||||
context_.check_arg_id(id);
|
||||
check_arg_id();
|
||||
}
|
||||
FMT_CONSTEXPR void on_arg_id(basic_string_view<Char>) {}
|
||||
FMT_CONSTEXPR void on_arg_id(basic_string_view<Char>) {
|
||||
on_error("compile-time checks don't support named arguments");
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR void on_replacement_field(const Char*) {}
|
||||
|
||||
@ -3495,6 +3497,16 @@ inline internal::udl_arg<wchar_t> operator"" _a(const wchar_t* s, std::size_t) {
|
||||
#endif // FMT_USE_USER_DEFINED_LITERALS
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
\rst
|
||||
Constructs a compile-time format string.
|
||||
|
||||
**Example**::
|
||||
|
||||
// A compile-time error because 'd' is an invalid specifier for strings.
|
||||
std::string s = format(FMT_STRING("{:d}"), "foo");
|
||||
\endrst
|
||||
*/
|
||||
#define FMT_STRING(s) \
|
||||
[] { \
|
||||
struct str : fmt::compile_string { \
|
||||
|
@ -2357,7 +2357,8 @@ TEST(FormatTest, FormatStringErrors) {
|
||||
EXPECT_ERROR("{:d}", "invalid type specifier", std::string);
|
||||
EXPECT_ERROR("{:s}", "invalid type specifier", void*);
|
||||
# endif
|
||||
EXPECT_ERROR("{foo", "missing '}' in format string", int);
|
||||
EXPECT_ERROR("{foo",
|
||||
"compile-time checks don't support named arguments", int);
|
||||
EXPECT_ERROR_NOARGS("{10000000000}", "number is too big");
|
||||
EXPECT_ERROR_NOARGS("{0x}", "invalid format string");
|
||||
EXPECT_ERROR_NOARGS("{-}", "invalid format string");
|
||||
|
Loading…
Reference in New Issue
Block a user