Alias on an array element
    solidstate1991 
    laszloszeremi at outlook.com
       
    Fri Oct 13 01:09:56 UTC 2017
    
    
  
I'm making a struct for easy color handling Here's a code sample:
ublic struct Color{
	union{
		uint raw;	///Raw representation in integer form, also forces 
the system to align in INT32.
		ubyte[4] colors;	///Normal representation, aliases are used for 
color naming.
		ubyte alpha, red, green, blue;
	}
	version(LittleEndian){
		alias alpha = colors[0];
		alias red = colors[1];
		alias green = colors[2];
		alias blue = colors[3];
	}else{
		alias alpha = colors[3];
		alias red = colors[2];
		alias green = colors[1];
		alias blue = colors[0];
	}
}
All the aliases are fail to compile, have not found anything 
about it in any of the documentations I checked.
    
    
More information about the Digitalmars-d-learn
mailing list