Jared Hoberock Jared Hoberock - 2 months ago 7
C++ Question

Will the C++ Concepts TS enable multiple parameter packs?

In C++14, it is not possible to call a function template with multiple parameter packs:

#include <future>

template<class... Futures, class... Incrementables>
void foo(Futures&... futures, Incrementables... incrementables)
{
}

int main()
{
std::future<int> a, b;
int x, y;

// ERROR
foo(a, b, x, y);

return 0;
}


Because it's not clear where the first parameter pack ends and the second one begins, it's not possible to call
foo
without additional information provided by the programmer.

However, it seems like the two parameter packs could be disambiguated in principle, given proper Concepts for
Future
and
Incrementable
.

Will any features of the upcoming C++ Concepts Technical Specification relax these restrictions and allow calling a function template with more than one parameter pack?

Answer

The constraint system of Concepts Lite sits on top of the existing template machinery. In particular, it does not interfere with template argument deduction. The Futures pack is non-deducible in your example, and will remain so even with concepts.

However, it seems like the two parameter packs could be disambiguated in principle, given proper Concepts for Future and Incrementable.

You may not have picked the best example here, although that doesn't really make the premise of your question any less interesting. What do you make of this?

Future{Fut}
struct incrementable_future: Fut {
    using Fut::Fut;

    incrementable_future& operator++() { return *this; }
};