template <typename T>
struct X
{
template <typename Iter>
X(Iter a, Iter b) {}
template <typename Iter>
auto f(Iter a, Iter b)
{
return X(a, b);
}
};
In the "C++ Templates, The Complete Guide" 2nd edition, there was the previous example about the subtitles of implicit deduction guides with injected class names. The author mentioned that class argument deduction is disabled for injected class names because the type of the return of f would be X<Iter>
due to the implicit deduction guide. But I believe the implicit deduction guide for a template constructor would rather look like the one below.
template <typename T, typename Iter>
X(Iter a, Iter b) -> X<T>;
My question is how would the class template argument types even be deduced in that case T
and Iter
are two distinct types and the parameters types only rely on Iter
. Also even if T could be deduced somehow, T
and Iter
are independent so deducing Iter
from the arguments should not imply that X
has type X<Iter>
right? Is this some error with the text in the book or should the deduction guide look different from what I thought?