函数模板重载clang ++ [英] function template overloading clang++
本文介绍了函数模板重载clang ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
g ++ 4.8.1和clang ++ 3.4对于下一个代码给出不同的结果:
g++ 4.8.1 and clang++ 3.4 give different results for next code:
// simplified code from a Logger module
#include <iostream>
template<class T> void tf(const T*) { // clang++
std::cout << "void tf(const T*)\n";
}
template<class T> void tf(T) { // g++
std::cout << "void tf(T)\n";
}
int main(){
typedef std::ios_base& (*ph)(std::ios_base&);
ph p = std::hex;
tf(p); // or just tf(std::hex)
}
我不知道哪种变体是正确的(C ++ 03)。
I can't figure out which variant is correct (C++ 03).
推荐答案
我试图将其作为bug提交给llvm bugzill。答案是:
I've tried to submit this as a bug to llvm bugzill. The answer was:
这是一个GCC错误。请参阅:
This is a GCC bug. See:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1584
这篇关于函数模板重载clang ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文