“controlled_runge_kutta”不是类模板

‘controlled_runge_kutta’ is not a class template

本文关键字:controlled runge kutta      更新时间:2023-10-16

这是以下代码中的已知错误:

"controlled_runge_kutta"不是类模板

在下面的代码中:

template<
class ErrorStepper ,
class ErrorChecker ,
class Resizer
>
class controlled_runge_kutta< ErrorStepper , ErrorChecker , Resizer , explicit_error_stepper_tag >
{
public:
};
int main()
{
    return 0;
}

我知道为什么会出现此错误。但我的问题是,它在 github 第 146 行的原始 boost 库中是如何工作的?

谢谢。

请看第 109 行。

template<
class ErrorStepper ,
class ErrorChecker = default_error_checker< typename ErrorStepper::value_type ,
typename ErrorStepper::algebra_type ,
typename ErrorStepper::operations_type > ,
class Resizer = typename ErrorStepper::resizer_type ,
class ErrorStepperCategory = typename ErrorStepper::stepper_category
>
class controlled_runge_kutta;

现在,有模板类的声明,在第 146 行中,只有该类的部分专用化。

如果语法为:

template <template-parameters...> class NAME { ... };

然后是"主模板定义"。如果是:

template <template-parameters...> class NAME<parameter-spec> { ... };

然后是部分模板专用化(为参数的特殊情况定义"映射"的辅助定义(。

如果尚未提供该名称(类或函数模板(的主模板定义,则无法声明部分模板专用化。

因此,取决于您要声明的内容。如果只是一个模板 - 然后删除类名后面的所有内容<...>。如果是专业化,那么请先定义模板本身。

template<...>语句在主定义和专业化中的含义不同。在主定义中,它定义了"签名"(应该如何调用"实例化"(,在专业化中,它只意味着提供一些内部使用的名称。