Output ranges and arrays

Olivier Pisano olivier.pisano at laposte.net
Fri Nov 12 06:22:20 PST 2010


Hi,

I am starting to play with output ranges and have trouble understanding 
how they do work on arrays. Consider the following code :

	import std.array;
	import std.range;
	import std.stdio;

	void main(string[] argv)
	{
	    auto a = [1, 2, 3];
	    a.put(4);

	    writefln("%s", a);
	}

One could expect the call to put() to append 4 to the array so the array 
content would be [1, 2, 3, 4].
Instead of this, I get "[2, 3]" to be printed. So I guess put() is 
translated to

	r.front = e; r.popFront();

as written in std.range.put documentation.

Is it the expected behaviour or is it a bug ?

Cheers,

Olivier.


More information about the Digitalmars-d mailing list