I want to deduce the template arguments of an aliased class template and Richard Smith says that should work in C++20.
If my alias is just a name-change, then this answer to a related question works with C++20:
template <typename T> struct Bar { Bar(T); };
template <typename T> using Foo = Bar<T>;
template <typename T> Bar(T) -> Bar<T>; // decuction guide here
Foo f{42};
However, my alias is not just a simple name-change, but something more involved, and I only want to deduce when used as alias. For the sake of argument, let's say:
template <typename T> struct MyVector{ MyVector(T); };
template <typename T> struct Bar { Bar(T); };
template <typename T> using BarVec = MyVector<Bar<T>>;
// how to tell the compiler that BarVec(int) should construct a
// MyVector<Bar<int>> without forcing all constructor calls for
// MyVector(int) to construct MyVector<Bar<int>> ?
// maybe like this?
template<typename T> BarVec(T) -> BarVec<T>;
// NO, error: "cannot specify deduction guide for alias template"
// suggested in the comments:
template<typename T> MyVector(T) -> MyVector<Bar<T>>;
// the compiler accepts this, but now all MyVector(T) calls create
// a MyVector<Bar<T>> which is not what I want
BarVec bv{42}; // I want this to deduce MyVector<Bar<int>>
MyVector mv{42} // I want this to deduce to MyVector<int>
See my attempts in inline comments. Play with it here.
CTAD for alias templates in C++20 does not permit declaring new deduction guides specific for the alias template. The deduction guides used for CTAD are instead derived from the class template that the alias template aliases. You can't make it deduce in the way you want.