You can achieve the HexAdapter<std::vector>
syntax by relying on a template template parameter, i.e., a template parameter which is, in turn, a class template (or an alias template):
struct Cell { /* ... */ };
template<template<typename...> class Cont>
class HexAdapter {
Cont<Cont<Cell>> hexCells;
/* ... */
};
The template argument to the class template HexAdapter
(i.e., the argument to the Cont
parameter) must be a class template itself (e.g., std::vector
or std::deque
):
auto main() -> int {
HexAdapter<std::vector> foo;
HexAdapter<std::deque> bar;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…