Конечно, вы можете иметь параметры шаблона по умолчанию:
template <typename T, typename U, typename V = U>
template <typename T, typename U = int, typename V = std::vector<U> >
Стандартная библиотека делает это постоянно - большинство контейнеров принимают от двух до пяти параметров! Например, unordered_map
на самом деле:
template<
class Key, // needed, key type
class T, // needed, mapped type
class Hash = std::hash<Key>, // hash functor, defaults to std::hash<Key>
class KeyEqual = std::equal_to<Key>, // comparator, defaults to Key::operator==()
class Allocator = std::allocator<std::pair<const Key, T>> // allocator, defaults to std::allocator
> class unordered_map;
Обычно вы просто используете его как std::unordered_map<std::string, double>
, не задумываясь об этом.