Skip to content

Commit

Permalink
Merge pull request #4711 from JackStouffer/patch-20
Browse files Browse the repository at this point in the history
[trivial] Improved some docs in std.stdio
  • Loading branch information
DmitryOlshansky authored Aug 10, 2016
2 parents b2aacbf + e936f33 commit 41a1d2b
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -3258,14 +3258,20 @@ struct LockingTextReader
}

/**
* Indicates whether $(D T) is a file handle of some kind.
* Indicates whether $(D T) is a file handle, i.e. the type
* is implicitly convertable to $(LREF File) or a pointer to a
* $(REF FILE, core,stdc,stdio).
*
* Returns:
* `true` if `T` is a file handle, `false` otherwise.
*/
template isFileHandle(T)
{
enum isFileHandle = is(T : FILE*) ||
is(T : File);
}

///
@safe unittest
{
static assert(isFileHandle!(FILE*));
Expand All @@ -3275,14 +3281,20 @@ template isFileHandle(T)
/**
* Property used by writeln/etc. so it can infer @safe since stdout is __gshared
*/
private @property File trustedStdout() @trusted { return stdout; }
private @property File trustedStdout() @trusted
{
return stdout;
}

/***********************************
For each argument $(D arg) in $(D args), format the argument (as per
$(LINK2 std_conv.html, to!(string)(arg))) and write the resulting
string to $(D args[0]). A call without any arguments will fail to
compile.
Params:
args = the items to write to `stdout`
Throws: In case of an I/O error, throws an $(D StdioException).
*/
void write(T...)(T args) if (!is(T[0] : File))
Expand All @@ -3307,9 +3319,15 @@ void write(T...)(T args) if (!is(T[0] : File))
}

/***********************************
* Equivalent to $(D write(args, '\n')). Calling $(D writeln) without
* Equivalent to `write(args, '\n')`. Calling `writeln` without
* arguments is valid and just prints a newline to the standard
* output.
*
* Params:
* args = the items to write to `stdout`
*
* Throws:
* In case of an I/O error, throws an $(LREF StdioException).
*/
void writeln(T...)(T args)
{
Expand Down

0 comments on commit 41a1d2b

Please sign in to comment.