Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何使用尾随返回类型分隔模板函数的声明和定义?_C++_Templates_Variadic_Trailing Return Type - Fatal编程技术网

C++ 如何使用尾随返回类型分隔模板函数的声明和定义?

C++ 如何使用尾随返回类型分隔模板函数的声明和定义?,c++,templates,variadic,trailing-return-type,C++,Templates,Variadic,Trailing Return Type,我偶然发现了与这个问题相同的问题:,但没有答案 基本上,我想写以下内容: 名称空间ALGLIB_包装器 { 类线性最小二乘法 { 公众: 模板 自动拟合(常数表和,基函数…函数)->std::数组; }; } 模板 自动ALGLIB_包装器::线性最小平方::拟合(常数表和势,基函数…函数)->标准::数组 { //代码 } 对于g++-9或g++10,我得到以下错误: ALGLIB_wrappers.h:151:6: error: no declaration matches ‘std::a

我偶然发现了与这个问题相同的问题:,但没有答案

基本上,我想写以下内容:

名称空间ALGLIB_包装器
{
类线性最小二乘法
{
公众:
模板
自动拟合(常数表和,基函数…函数)->std::数组;
};
}
模板
自动ALGLIB_包装器::线性最小平方::拟合(常数表和势,基函数…函数)->标准::数组
{
//代码
}
对于g++-9或g++10,我得到以下错误:

ALGLIB_wrappers.h:151:6: error: no declaration matches ‘std::array<double, sizeof... (funcs)> ALGLIB_wrappers::Linear_least_squares::fit(const Table&, Basis_function ...)’
  151 | auto ALGLIB_wrappers::Linear_least_squares::fit(const Table& potential, Basis_function... funcs) -> std::array<double, sizeof...(funcs)>
      |      ^~~~~~~~~~~~~~~
ALGLIB_wrappers.h:15:8: note: candidate is: ‘template<class Table, class ... Basis_function> std::array<double, sizeof... (funcs)> ALGLIB_wrappers::Linear_least_squares::fit(const Table&, Basis_function ...)’
   15 |   auto fit(const Table&, Basis_function... funcs) -> std::array<double, sizeof...(funcs)>;
      |        ^~~
ALGLIB_wrappers.h:8:8: note: ‘class ALGLIB_wrappers::Linear_least_squares’ defined here
    8 |  class Linear_least_squares
      |        ^~~~~~~~~~~~~~~~~~~~
ALGLIB_wrappers.h:151:6:错误:没有声明匹配的'std::array ALGLIB_wrappers::Linear_least_squares::fit(常数表和基函数…)
151 |自动ALGLIB_包装器::线性_最小二乘法::拟合(常数表和电势、基函数…函数)->标准::数组
|      ^~~~~~~~~~~~~~~
ALGLIB_wrappers.h:15:8:注:候选项是:“模板标准::数组ALGLIB_wrappers::线性最小二乘::拟合(常数表和基函数…)
15 |自动拟合(常数表和,基函数…funcs)->标准::数组;
|        ^~~
ALGLIB_wrappers.h:8:8:note:“类ALGLIB_wrappers::Linear_least_squares”在这里定义
8类线性最小二乘法
|        ^~~~~~~~~~~~~~~~~~~~
我不明白我做错了什么

有什么办法吗?

sizeof…(基本函数)
替换
sizeof…(函数)
似乎适用于g++,但我无法解释为什么


(请注意,您的代码使用的是clang++)

此外,使用-fchecking的g++表示编译器错误。仍然存在疑问:谁是对的?编译时发出的叮当声,还是给出错误的g++?