到目前为止,我的班级看起来像这样。
template< template<int dim, class T> class search_space> class abstract_search_algorithm {
private:
class search_space<dim, class T> & ssp; //error: dim not declared in scope
//public:
// abstract_search_algorithm(search_space<int dim, T>& ss) : ssp(ss) { }
// virtual std::array<T, dim> execute() = 0;
// virtual ~abstract_search_algorithm() { }
};
如您所见,search_algorithm
的参数将是模板类。现在,我想在agorithm类中存储对该类的引用,但它的正确类型是什么?
答案 0 :(得分:0)
您可以这样做:
template <typename T> class abstract_search_algorithm;
专业化:
template<template<int, class> class search_space, int dim, typename T>
class abstract_search_algorithm<search_space<dim, T>> {
// Your implementation.
};