looking for V[string] workarounds

Ali Çehreli acehreli at yahoo.com
Wed Mar 20 10:11:01 PDT 2013


On 03/20/2013 07:34 AM, Dan wrote:
> Can the following be made to build and run, but keep the intent of what
> is shown. I realize it touches on several bugs related to const,
> postblit, and map - but I'm having trouble finding the magic
> combination. The idea is simply have assets store multiple series of
> data in a map indexed by the asset name.
>
> Thanks,
> Dan
>
> import std.stdio;
> struct Series {
> // REQUIRED - need to have no aliasing
> this(this) { data = data.dup; }
> private double[] data;
> }
>
> struct Assets {
> this(this) { itemToSeries.dup; }
> // REQUIRED - want ctor to dup arg to ensure no aliasing
> this(const(Series[string]) source) {

The code compiles with 2.062 and an earlier version of 2.063 if you 
accept letting go of const-correctness there:

     this(Series[string] source) {

> itemToSeries = source.dup;
> }
> private Series[string] itemToSeries;
> }
>
> void main() {
> auto data = [ "house" : Series([1,2,3.0])];
> auto assets = Assets(data);
> writeln(assets);
> }

Ali


More information about the Digitalmars-d-learn mailing list