Is it possible to match recursively integer template parameters in C++?
问题 I have the following problem. I define a N dimensional vector as so #include <vector> #include <utility> #include <string> template <int N, typename T> struct NVector{ typedef std::vector<typename NVector<N-1,T>::type> type; }; template <typename T> struct NVector<1,T> { typedef std::vector<T> type; }; I wish to write a higher order function Map that can transform the leaf elements of the nested vector no matter how deep and return a new nested vector of the same shape. I have tried template