Yes, you can do a simple enumeration of templates using partial specialization:
#include <memory> #include <vector> template <typename> struct vector_rebinder; template <typename T, typename A> struct vector_rebinder<std::vector<T, A>> { template <typename U> using rebind = std::vector<U, typename std::allocator_traits<A>::template rebind_alloc<U>>; };
Using:
using T1 = std::vector<int>; using T2 = vector_rebinder<T1>::rebind<double>;
Now T2 is std::vector<double> .
source share