Const-correctness and uniqueness. Again.
Jakob Ovrum via Digitalmars-d
digitalmars-d at puremagic.com
Mon Feb 9 03:37:21 PST 2015
On Monday, 9 February 2015 at 10:56:31 UTC, Dicebot wrote:
> Consider this trivial snippet:
>
> ```D
> import std.array : join;
>
> void main()
> {
> auto s = join([ "aaa", "bbb", "ccc" ]);
> pragma(msg, typeof(s));
> }
> ```
>
> It outputs "string" which stands for immutable buffer.
The following works as well:
---
void main()
{
import std.array : join;
import std.stdio : writeln;
char[] s = join(["foo", "bar"]);
writeln(s); //foobar
}
---
std.array.join is strongly pure (with appropriate template
arguments), so its return value is implicitly convertible to
immutable.
More information about the Digitalmars-d
mailing list