Initializing structure that is a member of a const structure

Maksim Zholudev maximzms at gmail.com
Sun Mar 3 10:36:45 PST 2013


Trying to make my program care about const qualifier I've ended 
up with the following problem:
-----------------
struct Foo
{
     int* a;

     inout this(inout int* src) pure
     {
         a = src;
     }

     inout void opAssign(inout Foo f) pure
     {
         a = f.a; // Error: can only initialize const member a 
inside constructor
     }
}

struct Boo
{
     Foo foo;

     inout this(inout int* src) pure
     {
         foo = Foo(src);
     }
}
-----------------
This code would work even without opAssign but let's imagine we 
need it for some reason.
Is there any way to initialize `foo` without opAssign call?


More information about the Digitalmars-d-learn mailing list