Alias on an array element

solidstate1991 laszloszeremi at outlook.com
Fri Oct 13 01:12:38 UTC 2017


On Friday, 13 October 2017 at 01:09:56 UTC, solidstate1991 wrote:
> 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.

Edit: ubyte alpha, red, green, blue; was added so I can continue 
debugging after the refactoring until I find a solution.


More information about the Digitalmars-d-learn mailing list