clang 3.4 aşağıdaki kodu kabul eder; vc ise ++ Kasım 2013 CTP bir hata ile reddeder: C++ 14 standardına göre doğru derleyiciKod neden clang tarafından kabul edildi, ancak vC++ tarafından reddedildi mi?
error C2668: 'AreEqual' : ambiguous call to overloaded function
template<class headT, class... tailTypes>
constexpr headT&& __GetFirst__(headT&& value, tailTypes&&...)
{
return static_cast<headT&&>(value);
};
template<class T>
constexpr bool AreEqual(const T& a, const T& b)
{
return a == b;
}
template<class headT, class... tailTypes>
constexpr bool AreEqual(const headT& head_value, const tailTypes&... tail_values)
{
return AreEqual(head_value, __GetFirst__(tail_values...))
&& AreEqual(tail_values...);
}
int main()
{
AreEqual(1, 1, 2, 1);
}
?
Güncelleme: Tam hata iletisi:
error C2668: 'AreEqual' : ambiguous call to overloaded function
1> d:\projects\ktl\test\main.cpp(20): could be 'bool AreEqual<headT,int>(const headT &,const int &)'
1> with
1> [
1> headT=int
1> ]
1> d:\projects\ktl\test\main.cpp(8): or 'bool AreEqual<headT>(const T &,const T &)'
1> with
1> [
1> headT=int
1> , T=int
1> ]
1> while trying to match the argument list '(const int, const int)'
1>
1>Build FAILED.
Yan notu : '__GetFirst__' ayrılmış bir addır. –
Tüm hata mesajını lütfen gönderir misiniz? –
hangisinin doğru olduğunu bilmiyoruz, fakat kolay düzeltme, variadic 3 + params – sp2danny