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

Template function inside template inhibits inferring arguments when called #20851

Open
TurkeyMan opened this issue Feb 11, 2025 · 2 comments
Open

Comments

@TurkeyMan
Copy link
Contributor

TurkeyMan commented Feb 11, 2025

We all know about this, but I really reckon it's a bug and should be fixed.

template fun(T, U)
{
    void fun(T x, U y) {}
}

template fun2(T)
{
    void fun2(U)(T x, U y) {}
}

template fun3(T)
{
    alias fun3(U) = fun!(T, U);
}


void test()
{
    fun(1, 2); // arguments are inferred
    fun!int(1, 2); // T is given, but U is still inferred

//    fun2(1, 2); // ERROR: T is NOT inferred
    fun2!int(1, 2); // T is given, and U is inferred (inference works 'through' an outer template here)

//    fun3!int(1, 2); // ERROR: T is given, but U is NOT inferred?
    // why is this different than the `fun!int` case?
    // if you say the inference didn't work 'through' the outer template, then how do we explain the `fun2` case?
}

I feel like all the cases shown above should work, including the commented out ones.
Especially the fun3 case; once the outer template is applied, the situation should be the same as fun!int...

Basically, as I see it now; the first case with fun feels like a hack in the language, where the hack was applied to a specific edge case, rather than this concept being implemented seamlessly.

@pbackus
Copy link
Contributor

pbackus commented Feb 11, 2025

The fun3 case is just Bugzilla 1807 again.

@Herringway
Copy link
Contributor

The fun3 case is just Bugzilla 1807 again.

(#17667)

@thewilsonator thewilsonator changed the title Tempalte function inside template inhibits inferring arguments when called Template function inside template inhibits inferring arguments when called Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants