Variadic Template: cast problem

Dmitry Olshansky dmitry.olsh at gmail.com
Sat Aug 4 07:05:26 PDT 2012


On 04-Aug-12 17:57, Namespace wrote:
> This code http://dpaste.dzfl.pl/6caed813 does only compile if i comment
> out the "Clone" method. Why? o.O

Because it calls constructor and fails? I've done substitution for you:
this(const vec!(float,2) values) {
		foreach (index, val; values) {
			this.values[index] = cast(T) val;
		}
	}

No big wonder.

I'd try to fix Clone to:
{
vec!(T, dim) tmp = void;
tmp.values = this.values;
return tmp;
}

-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list