I have a class template:
template <typename T, std::size_t N>
class iterator
{
explicit iterator(T*);
};
I tried using the c++17 feature Class template argument deduction (CTAD)
to deduce T
, but I can't do so, since there is no way to deduce N
and specifying N
means CTAD will not be attempted anyway. So I went the old-fashioned way:
template <std::size_t N, typename T>
auto make_iterator(T* const p)
{
return iterator<T, N>(p);
}
This allows me to only provide N
and T
is deduced. Is there a c++20 (and beyond) feature I overlooked, that would allow me to dispense with this function? I tried this:
template <std::size_t N, typename T>
iterator(T*) -> iterator<T, N>;
But, it doesn't work, as:
Class template argument deduction is only performed if no template argument list is present. If a template argument list is specified, deduction does not take place.