[英]clang: candidate template ignored: substitution failure: typedef 'type' cannot be referenced with a class specifier
In contrast to GCC 5, Clang 6 complains about the following error:与 GCC 5 相比,Clang 6 抱怨以下错误:
candidate template ignored: substitution failure [with U = char, Us = ]: typedef 'type' cannot be referenced with a class specifier Tuple(U&& u, Us&&... rest) : m_element(::std::forward(u)), m_rest(::std::forward(rest...)...)候选模板被忽略:替换失败 [with U = char, Us = ]: typedef 'type' 不能用类说明符引用 Tuple(U&& u, Us&&... rest) : m_element(::std::forward(u) ), m_rest(::std::forward(rest...)...)
I use my own Tuple implementation with我使用我自己的元组实现
//! Declaration of tuple typename with multiple elements
template<typename T, typename... Ts>
class Tuple<T, Ts...>
{
public:
T m_element;
Tuple<Ts...> m_rest;
template<typename U,
typename... Us,
typename = class ::std::enable_if<!::std::is_base_of<Tuple,typename ::std::decay<U>::type>::value>::type>
Tuple(U&& u, Us&&... rest) : m_element(::std::forward<U>(u)), m_rest(::std::forward<Us>(rest)...)
{
}
};
template<typename... Ts>
Tuple<typename ::std::decay<Ts>::type...> make_tuple(Ts&&... elements)
{
return Tuple<typename ::std::decay<Ts>::type...>(::std::forward<Ts>(elements)...);
}
What is clang doing differently than GCC?铿锵与 GCC 有何不同? And how can I fix this?我该如何解决这个问题?
Thanks!谢谢!
What is clang doing differently than GCC?铿锵与 GCC 有何不同? And how can I fix this?我该如何解决这个问题?
Non sure who's right and not sure this solve your problem (without a minimal but complete example of your problem I can't check it) but I have an error (clang++ only) that disappear when I change a class
with a typename
不知道谁是正确的,并不能肯定这解决您的问题(没有你的问题的一小部分,但完整的例子,我不能检查它),但我有一个错误(铛++只),其消失的时候我改变class
与typename
So I suggest所以我建议
template<typename U,
typename... Us,
// ........VVVVVVVV <--- "typename" here, not "class"
typename = typename ::std::enable_if<!::std::is_base_of<Tuple,typename ::std::decay<U>::type>::value>::type>
Tuple(U&& u, Us&&... rest) : m_element(::std::forward<U>(u)),
m_rest(::std::forward<Us>(rest)...)
{ }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.