课堂内的C 模板
c++ template within class
我在通过一个函数及其参数的类中具有一个函数,然后将它们绑定到函数调用中,并调用函数。
这已经很快被黑客入侵,以测试一个我知道代码不好的概念。
class Profiling {
public:
template<class _Fn, class... _Args> GetProfile(_Fn&& _Fx, _Args&&... _Ax);
int GetTime();
char Type;
int Size;
private:
int StartTime;
int EndTime;
};
template<class _Fn, class... _Args> Profiling::GetProfile(_Fn&& _Fx, _Args&&... _Ax)
{
StartTime = clock();
function<void()> f = _STD bind(_Decay_copy(_STD forward<_Fn>(_Fx)), _Decay_copy(_STD forward<_Args>(_Ax))...);
f();
EndTime = clock();
}
int Profiling::GetTime() {
return EndTime - StartTime;
}
我得到此错误
错误2错误c4430:缺少类型指定符 - 假定int。注意:C 不支持Default-Int
任何帮助都非常感谢。
您缺少函数的返回类型。
template<class _Fn, class... _Args>
/* return type here */ GetProfile(_Fn&& _Fx, _Args&&... _Ax);
由于您不返回该功能中的任何内容,因此void
将是适当的返回类型。
相关文章:
- .cpp和.h文件中的模板专用化声明
- C++模板来检查友元函数的存在
- 如何使用默认参数等选择模板专业化
- 模板参数替换失败,并且未完成隐式转换
- 具有默认模板参数的多态类的模板推导失败
- 部分定义/别名模板模板参数
- 模板-模板参数推导:三个不同的编译器三种不同的行为
- 具有奇怪重复模板模式的派生类中的成员变量已损坏
- 如何在c++中为模板函数实例创建快捷方式
- 使用C++中的模板和运算符重载执行矩阵运算
- 有人能分解一下这个c++模板的语法吗
- 如何在c++17中制作一个模板包装器/装饰器
- 模板化建造师专业化
- 调用专用模板时出错"no matching function for call to [...]"
- 模板元程序查找相似的连续类型名称
- 如何在C++20中创建模板别名的推导指南
- 课堂中成员函数模板的明确实例
- 课堂内的C 模板
- 在课堂中使用模板中的混乱
- 课堂上的模板专业化