我可以给一个模板函数的具体实例化一个名字,这样它就可以被称为一个类似于非模板函数吗?
例如,
// some template function
template <typename T>
void foo(T t) {...}
// I would like int_foo to behave like a regular function with
// foo<int> as its implementation (obviously this doesn't compile because
// using cannot be used like this)
using int_foo = foo<int>;
一种方法是委托并依靠内联来完成其余的工作,比如:
void int_foo(int i) {
foo<int>(i);
}
..。但如果有更直接的方法,我会洗耳恭听。
发布于 2019-06-16 02:22:38
不,没有,它不需要30个字符,但所有答案都需要。
https://stackoverflow.com/questions/56615498
复制相似问题