Я пытаюсь составить двойной список какого-то типа.В данном случае это двойной список «BoardCell».Вот моя реализация для List:
template<typename T, typename... TT>
struct List {
typedef T head;
typedef List<TT...> next;
constexpr static int size = 1 + next::size;
};
template<typename T>
struct List<T> {
typedef T head;
constexpr static int size = 1;
};
А вот реализация для BoardCell: (когда "CellType" и "Direction" являются перечислениями)
template<CellType CT, Direction D, int L>
struct BoardCell {
constexpr static CellType type = CT;
constexpr static Direction direction = D;
constexpr static int length = L;
};
теперь я пытаюсь сделатьGameBoard.Это моя попытка, и я не могу найти, почему она не работает:
template<template<template<template<CellType C, Direction D, int L> class BoardCell> class List> class List>
struct GameBoard {
typedef List<List<BoardCell<C, D, L>>> board;
};
(Да, это вложенный шаблон x3 :() Я считаю, что строка шаблона хороша, а typedefпроблема в плате.
Правка - ДОБАВЛЕНИЕ: Вот пример для ввода GameBoard:
typedef GameBoard<List< List< BoardCell<EMPTY, UP, 0>, BoardCell<EMPTY, UP, 0>>,
List< BoardCell<X, RIGHT, 1>, BoardCell<A, UP, 1>>,
List< BoardCell<EMPTY, UP, 0>, BoardCell<EMPTY, UP, 0>>>> gameBoard;
Я не использую std :: tuple, потому что это часть Домашней работы инам нужно реализовать также список.