Is there a way to initialize a non-assigned structure declaration (or is it a definition)?

Too Embarrassed To Say kheaser at eapl.org
Fri Nov 9 15:35:05 PST 2012


struct Parameterized(T, U, V, W)
{
    T t;
    U u;
    V v;
    W w;
    this(T t, U u, V v, W w)
    {
       this.t = t;
	  this.u = u;
	  this.v = v;
	  this.w = w;
    }
}

Parameterized!(int, double, bool, char) p1; // compiles
// or
auto p2 = Parameterized!(int, double, bool, char)();  // must 
have the empty () to compile
// or
auto p3 = Parameterized!(int, double, bool, char)(57, 7.303, 
false, 'Z');  // compiles
// but not
// Parameterized!(int, double, bool, char)(93, 5.694, true, 'K')  
p4;
// Error: found 'p4' when expecting ';' following statement
// nor
// Parameterized!(int, double, bool, char)  p5(93, 5.694, true, 
'K');
// Error: found 'p5' when expecting ';' following statement
// nor, OK this was a crazy try
// Parameterized!(int 93, double 5.694, bool true, char 'K')  p6;
// Error: found '93' when expecting '.' following int


More information about the Digitalmars-d-learn mailing list