You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code does not currently compile:
import std.meta : AliasSeq;AliasSeq!(int, float) a;auto b = cast(AliasSeq!(byte, byte))a;
Casting a set of values to a set of types is something that comes up every now and then. It can currently be done using a variation of this function:
template castTuple(T...) { auto castTuple(Args...)(Args args) if (Args.length == T.length) { static if (T.length == 0) { return tuple(); } else { auto result = .castTuple!(T[1..$])(args[1..$]); return tuple(cast(T[0])args[0], result.expand); } }}
The compiler however, has all the necessary information to make the first example compile.
The text was updated successfully, but these errors were encountered:
Simen Kjaeraas reported this on 2017-09-07T13:50:43Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=17815
Description
The following code does not currently compile: import std.meta : AliasSeq; AliasSeq!(int, float) a; auto b = cast(AliasSeq!(byte, byte))a; Casting a set of values to a set of types is something that comes up every now and then. It can currently be done using a variation of this function: template castTuple(T...) { auto castTuple(Args...)(Args args) if (Args.length == T.length) { static if (T.length == 0) { return tuple(); } else { auto result = .castTuple!(T[1..$])(args[1..$]); return tuple(cast(T[0])args[0], result.expand); } } } The compiler however, has all the necessary information to make the first example compile.The text was updated successfully, but these errors were encountered: