小编Rah*_*arg的帖子

C++中的模板疑问

#include <iostream>
using namespace std;
template<typename T> void test()
{
     cout << "Called from template T";
}
template<int I> void test()
{
     cout << "Called from int";
}
int main()
{
     test<int()>();      
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码片段中test<int()>()调用第一个版本并提供输出

Called from template T

为什么不调用第二个版本?

c++ templates

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

标签 统计

c++ ×1

templates ×1