Re: std.array.array and immutable elements

2014-11-07 Thread John Colvin via Digitalmars-d-learn
On Friday, 7 November 2014 at 14:33:00 UTC, Jack Applegame wrote: DMD64 D Compiler v2.066.1 Why second call doesn't compile? import std.array; import std.algorithm; class Foo { bool flag; } void main() { immutable(Foo)[] foos; foreach(i; 0..5) foos ~= new Foo; // compiles

Re: std.array.array and immutable elements

2014-11-07 Thread ketmar via Digitalmars-d-learn
On Fri, 07 Nov 2014 15:18:24 + anonymous via Digitalmars-d-learn wrote: > On Friday, 7 November 2014 at 14:57:56 UTC, ketmar via > Digitalmars-d-learn wrote: > > `map` cannot return range with immutable elements, 'cause they > > are > > obviously generated by program, and therefore aren't >

Re: std.array.array and immutable elements

2014-11-07 Thread anonymous via Digitalmars-d-learn
On Friday, 7 November 2014 at 14:57:56 UTC, ketmar via Digitalmars-d-learn wrote: `map` cannot return range with immutable elements, 'cause they are obviously generated by program, and therefore aren't "immutable". That's not true. Runtime generated values can be immutable just fine. And it's

Re: std.array.array and immutable elements

2014-11-07 Thread ketmar via Digitalmars-d-learn
On Fri, 07 Nov 2014 14:32:57 + Jack Applegame via Digitalmars-d-learn wrote: > import std.array; > import std.algorithm; > > class Foo { > bool flag; > } > void main() { >immutable(Foo)[] foos; >foreach(i; 0..5) foos ~= new Foo; > >// compiles, typeof(bar1) == immuta

Re: std.array.array and immutable elements

2014-11-07 Thread ketmar via Digitalmars-d-learn
On Fri, 07 Nov 2014 14:32:57 + Jack Applegame via Digitalmars-d-learn wrote: ah, sorry, my bad, 'const' will not work to, for the same reason. signature.asc Description: PGP signature

std.array.array and immutable elements

2014-11-07 Thread Jack Applegame via Digitalmars-d-learn
DMD64 D Compiler v2.066.1 Why second call doesn't compile? import std.array; import std.algorithm; class Foo { bool flag; } void main() { immutable(Foo)[] foos; foreach(i; 0..5) foos ~= new Foo; // compiles, typeof(bar1) == immutable(Foo)[] auto bar1 = array(foos.filter!