未调用数组的函数专用化
Function specialization for arrays not being called
我有一个函数,它在其参数上模板化:
template <class Vector>
void F(Vector& vec);
我想为数字数组添加此函数的专用化。 我的尝试如下所示:
template <class NumType>
void F(NumType array[]);
我在调用代码中的专用函数时遇到困难。 见下文:
void main()
{
double a[] = {0.0, 1.0};
F(a); // This calls the Vector version of the function,
// with Vector = double [3], in my specific case.
}
如果它有帮助,我事先知道该函数需要一个长度为 3 的数组才能正常工作。
如何修复我的专用函数声明,以便调用函数的 NumType 数组版本?
谢谢
尝试
template <class NumType, size_t N>
void F(NumType (&array)[N]);
相关文章:
- 字符串化递归的"std::vector<std::vector<...>>"而不使用部分模板函数专用化
- 具有常量引用参数的函数模板专用化
- 在 C++20 中是否不再允许在 std 中对程序定义类型的函数模板进行专用化?
- C++模板专用化 - 无法匹配函数定义
- 具有专用化的模板类中的可靠条件复制和移动构造函数
- 如何使专用函数模板成为某个类的朋友?
- 如何按类型为元组元素创建专用函数
- 无法访问专用函数
- 使用指向部分专用函数成员的指针自动填充向量
- 64 位 G++ 4.6.3 不会在专用函数模板中将长整型视为长整型,即使它们的大小相同。这是一个错误吗?
- 操作员过载的专用函数
- C++调用模板专用函数
- 模板类中专用函数的声明
- 使用专用函数对异构集合的 STL 算法
- C++专用函数-不在此范围内错误
- 为什么我不能专用函数模板?
- 用于专用函数参数的模板
- 代码重复和模板专用化(当专用函数具有不同的返回类型时)
- 具有专用函数的Pull-Apart函数类型
- 专用函数模板