C++ Logo

std-proposals

Advanced search

[std-proposals] Template parameter packs followed by more types

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 22 May 2024 12:10:42 +0100
The following program fails to compile in C++23:

    template<typename... A, typename B>
    void Func(A&&... a, B &&b)
    {

    }

    int main(void)
    {
        Func(1, 5.2);
    }

Forgetting about how computer programming languages and compilers work
for a minute -- if we just try to apply simple reasoning here, it
would make sense that Func would be instantiated as follows:
    A = int
    B = double

It would make sense for the above program to be equivalent to:

    void Func(int &&a, double &&b)
    {

    }

    int main(void)
    {
        Func(1, 5.2);
    }

Is there any reason why C++26 cannot be amended to allow this?

Received on 2024-05-22 11:10:54