Trouble with std.Variant

ddos via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 18 14:06:08 PDT 2014


The following code fails because Vec2.length() does not return 
int ... so Variant is only usable with types that do not have a 
method with name length() ?? i'm confused

On Thursday, 18 September 2014 at 21:03:47 UTC, ddos wrote:
> struct Vec2
> {
> 	float[2] vec;
>
> 	public float length()
> 	{
> 		return sqrt(vec[0]*vec[0]+vec[1]*vec[1]);
> 	}
> }
>
> int main(string[] argv)
> {
> 	Vec2 test;
> 	Variant v = test;
>     return 0;
> }



More information about the Digitalmars-d-learn mailing list