小编Bal*_*aji的帖子

如何显式实例化模板函数?

我有一个带有一个参数的模板函数.我必须实例化该函数而不调用该函数意味着我必须实例化.

我有这个功能:

template <class T> int function_name(T a) {}
Run Code Online (Sandbox Code Playgroud)

我实例化了这样的函数:

template int function_name<int>(int);
Run Code Online (Sandbox Code Playgroud)

但是我遇到了以下错误:

error: expected primary-expression before 'template'
error: expected `;' before 'template'
Run Code Online (Sandbox Code Playgroud)

c++ templates

110
推荐指数
3
解决办法
7万
查看次数

标签 统计

c++ ×1

templates ×1