Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-09 Thread Dfr
Hello, here is example code, which doesn't work: Variant[] vtypes = [ Variant("hello"), Variant("bye") ]; string[] filetypes = map!(to!string)(vtypes); Gives me error: Error: cannot implicitly convert expression (map(vtypes)) of type MapResult!(to, VariantN!(24u)[]) to string[]

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-09 Thread Philippe Sigaud
On Tue, Dec 10, 2013 at 6:54 AM, Dfr wrote: > Hello, here is example code, which doesn't work: > > Variant[] vtypes = [ Variant("hello"), Variant("bye") ]; > string[] filetypes = map!(to!string)(vtypes); > > Gives me error: > > Error: cannot implicitly convert expression (map(vtypes)) of t

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-10 Thread Dfr
Thank you for good explanation. But i currently hit little more complex case and again stuck, maybe some ideas how to resolve this, unfortunately compiler messages not very explanatory. void main() { Variant[] lols = [ Variant(["hello": Variant(1)]), Variant(["bye": Variant(true)]) ];

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-10 Thread bearophile
Dfr: auto vtypes = map!(to!Variant[string])(lols); The short template instantiation syntax only supports a single token, to avoid mistakes,so you need to add (): map!(to!(Variant[string]))(lols); That is better written: lols.map!(to!(Variant[string])); But I don't know if this is eno

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-10 Thread Philippe Sigaud
> void main() > { > Variant[] lols = [ Variant(["hello": Variant(1)]), Variant(["bye": > Variant(true)]) ]; > auto vtypes = map!(to!Variant[string])(lols); // <--- line 11 > > string[] filetypes = map!(to!string)(vtypes).array(); > writeln(filetypes); > } > > Gives me: > main.d(11)

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-10 Thread Dfr
Thank you, this clears thing to me. I currently has all stuff wrapped in Variants because it is structure parsed from xml (or json), and it could be for example map of Something[string], where Something could be string or array or another map, and also this all nested few levels deep. I'm ne

Re: Using std.algorithm.map: Error: cannot implicitly convert expression of type MapResult!

2013-12-10 Thread Philippe Sigaud
On Wed, Dec 11, 2013 at 7:26 AM, Dfr wrote: > > Thank you, this clears thing to me. > > I currently has all stuff wrapped in Variants because it is structure parsed > from xml (or json), and it could be for example map of Something[string], > where Something could be string or array or another map