mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 15:10:46 +03:00
Document compile-time checking for format strings
This commit is contained in:
parent
3aa8011a04
commit
d20056974a
2 changed files with 23 additions and 19 deletions
|
@ -579,7 +579,7 @@ can match the expected number of readings or fewer, even zero, if a
|
||||||
matching failure happens.
|
matching failure happens.
|
||||||
|
|
||||||
Throws:
|
Throws:
|
||||||
An `Exception` if `S.length == 0` and `fmt` has format specifiers
|
An `Exception` if `S.length == 0` and `fmt` has format specifiers.
|
||||||
*/
|
*/
|
||||||
uint formattedRead(alias fmt, R, S...)(ref R r, auto ref S args)
|
uint formattedRead(alias fmt, R, S...)(ref R r, auto ref S args)
|
||||||
if (isSomeString!(typeof(fmt)))
|
if (isSomeString!(typeof(fmt)))
|
||||||
|
|
40
std/stdio.d
40
std/stdio.d
|
@ -1450,6 +1450,12 @@ Throws: $(D Exception) if the file is not opened.
|
||||||
Writes its arguments in text format to the file, according to the
|
Writes its arguments in text format to the file, according to the
|
||||||
format string fmt.
|
format string fmt.
|
||||||
|
|
||||||
|
Params:
|
||||||
|
fmt = The $(LINK2 std_format.html#format-string, format string).
|
||||||
|
When passed as a compile-time argument, the string will be statically checked
|
||||||
|
against the argument types passed.
|
||||||
|
args = Items to write.
|
||||||
|
|
||||||
Throws: $(D Exception) if the file is not opened.
|
Throws: $(D Exception) if the file is not opened.
|
||||||
$(D ErrnoException) on an error writing to the file.
|
$(D ErrnoException) on an error writing to the file.
|
||||||
*/
|
*/
|
||||||
|
@ -1471,13 +1477,7 @@ Throws: $(D Exception) if the file is not opened.
|
||||||
formattedWrite(lockingTextWriter(), fmt, args);
|
formattedWrite(lockingTextWriter(), fmt, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// Equivalent to `file.writef(fmt, args, '\n')`.
|
||||||
Writes its arguments in text format to the file, according to the
|
|
||||||
format string fmt, followed by a newline.
|
|
||||||
|
|
||||||
Throws: $(D Exception) if the file is not opened.
|
|
||||||
$(D ErrnoException) on an error writing to the file.
|
|
||||||
*/
|
|
||||||
void writefln(alias fmt, A...)(A args)
|
void writefln(alias fmt, A...)(A args)
|
||||||
if (isSomeString!(typeof(fmt)))
|
if (isSomeString!(typeof(fmt)))
|
||||||
{
|
{
|
||||||
|
@ -1786,9 +1786,12 @@ is recommended if you want to process a complete file.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads data from the file according to the specified
|
* Reads formatted _data from the file using $(REF formattedRead, std,_format).
|
||||||
* $(LINK2 std_format.html#_format-string, _format specifier) using
|
* Params:
|
||||||
* $(REF formattedRead, std,_format).
|
* format = The $(LINK2 std_format.html#_format-string, _format string).
|
||||||
|
* When passed as a compile-time argument, the string will be statically checked
|
||||||
|
* against the argument types passed.
|
||||||
|
* data = Items to be read.
|
||||||
* Example:
|
* Example:
|
||||||
----
|
----
|
||||||
// test.d
|
// test.d
|
||||||
|
@ -3701,11 +3704,9 @@ void writeln(T...)(T args)
|
||||||
Writes formatted data to standard output (without a trailing newline).
|
Writes formatted data to standard output (without a trailing newline).
|
||||||
|
|
||||||
Params:
|
Params:
|
||||||
fmt = The format string, specifying
|
fmt = The $(LINK2 std_format.html#format-string, format string).
|
||||||
how to format the rest of the arguments. For a full description of the syntax
|
When passed as a compile-time argument, the string will be statically checked
|
||||||
of the format string and how it controls the formatting of the rest of the
|
against the argument types passed.
|
||||||
arguments, please refer to the documentation for $(REF formattedWrite,
|
|
||||||
std,format).
|
|
||||||
args = Items to write.
|
args = Items to write.
|
||||||
|
|
||||||
Note: In older versions of Phobos, it used to be possible to write:
|
Note: In older versions of Phobos, it used to be possible to write:
|
||||||
|
@ -3814,9 +3815,12 @@ void writefln(Char, A...)(in Char[] fmt, A args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read data from $(D stdin) according to the specified
|
* Reads formatted data from $(D stdin) using $(REF formattedRead, std,_format).
|
||||||
* $(LINK2 std_format.html#_format-string, _format specifier) using
|
* Params:
|
||||||
* $(REF formattedRead, std,_format).
|
* format = The $(LINK2 std_format.html#_format-string, _format string).
|
||||||
|
* When passed as a compile-time argument, the string will be statically checked
|
||||||
|
* against the argument types passed.
|
||||||
|
* args = Items to be read.
|
||||||
* Example:
|
* Example:
|
||||||
----
|
----
|
||||||
// test.d
|
// test.d
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue