Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow casting of AliasSeq #19314

Open
dlangBugzillaToGithub opened this issue Sep 7, 2017 · 0 comments
Open

Allow casting of AliasSeq #19314

dlangBugzillaToGithub opened this issue Sep 7, 2017 · 0 comments
Labels

Comments

@dlangBugzillaToGithub
Copy link

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.
@thewilsonator thewilsonator added the Feature:tuple AliasSeq label Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants