Re: storing pointers in Variants

2014-04-27 Thread Matt via Digitalmars-d-learn
On Sunday, 27 April 2014 at 00:48:53 UTC, Ali Çehreli wrote: I think the following is a start: import std.variant; class MyClass { Variant[string] store; void attach(T)(string key, ref T var) { store[key] = &var; } void set(T)(string key, T value) { *s

Re: storing pointers in Variants

2014-04-26 Thread Ali Çehreli via Digitalmars-d-learn
On 04/26/2014 04:08 PM, Matt wrote: I am trying to create a class that can do the following: --- int sample = 42; // myObj is an instance of the class I'm writing myObj.attach ("othername", sample); myObj.set ("othername", 69); writeln (myObj.get ("othername"), "\t", sample); // should produ

storing pointers in Variants

2014-04-26 Thread Matt via Digitalmars-d-learn
I am trying to create a class that can do the following: --- int sample = 42; // myObj is an instance of the class I'm writing myObj.attach ("othername", sample); myObj.set ("othername", 69); writeln (myObj.get ("othername"), "\t", sample); // should produce '69 69' --- Currently, my cla