Deduction guides and variadic class templates with variadic template constructors – mismatched argument pack lengths

To simplify your example further, it appears that GCC does not implement variadic template arguments in deduction guides: https://wandbox.org/permlink/4YsacnW9wYcoceDH I didn’t see any explicit mention of variadic templates in the wording for deduction guides in the standard or on cppreference.com. I see no interpretation of the standard that disallows this. Therefore I think this is … Read more

Variadic deduction guide not taken by g++, taken by clang++ – who is correct?

This is gcc bug 80871. The issue is, we end up with this set of candidates for deduction: template <class… Types, class… Args> list<Types…> __f(Args… ); // constructor template <class… Args> list<Args…> __f(Args… ); // deduction-guide Both are valid (Types… can deduce as empty in the first case), but the call here should be ambiguous … Read more

Why do auto and template type deduction differ for braced initializers?

There are two important reasons for templates not to do any deduction (the two that I remember in a discussion with the guy in charge) Concerns about future language extensions (there are multiple meanings you could invent – what about if we wanted to introduce perfect forwarding for braced init list function arguments?) The braces … Read more

What is the partial ordering procedure in template deduction

While Xeo gave a pretty good description in the comments, I will try to give a step-by-step explanation with a working example. First of all, the first sentence from the paragraph you quoted says: For each of the templates involved there is the original function type and the transformed function type. […] Hold on, what … Read more

What are template deduction guides and when should we use them?

Template deduction guides are patterns associated with a template class that tell the compiler how to translate a set of constructor arguments (and their types) into template parameters for the class. The simplest example is that of std::vector and its constructor that takes an iterator pair. template<typename Iterator> void func(Iterator first, Iterator last) { vector … Read more

What is a nondeduced context?

Deduction refers to the process of determining the type of a template parameter from a given argument. It applies to function templates, auto, and a few other cases (e.g. partial specialization). For example, consider: template <typename T> void f(std::vector<T>); Now if you say f(x), where you declared std::vector<int> x;, then T is deduced as int, … Read more