template <typename Function> void for_each_element(
const boost::tuples::null_type&, Function) {}
template <typename Tuple, typename Function> void
for_each_element(Tuple& t, Function func) {
func(t.get_head());
for_each_element(t.get_tail(),func);
}
根据上面的代码片段,我们是定义重载函数还是部分特化函数?
谢谢
最佳答案
不存在函数偏特化这样的东西。这是一个过载。
例如
template <typename T, typename U>
void foo(T t, U u);
template <typename T>
void foo<T, int>(T t, int u); // Illegal: no partial specialisation of functions
template <typename T>
void foo(T t, int u); // OK
小心 mixing specialisations with overloads ,因为它并不总是像您想象的那样工作。
关于c++ - 以下语句是函数重载还是函数偏特化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10668201/