another questionを理解しようとしているので、次のコードを取得することでこの例を単純化しました。テンプレート化されたクラスのテンプレート化されたメソッドの特殊化のためのclang ++自動復帰型エラー?
template <bool>
struct foo
{
template <typename T>
auto bar (int i)
{ return i; }
};
template <>
template <typename T>
auto foo<true>::bar (int i)
{ return i; }
int main()
{
return 0;
}
g ++ 4.9.2問題なくコンパイルできます。打ち鳴らす++ 3.5 int
と値を返す2 auto
のいずれかを代入する次のエラーを
tmp_003-14,gcc,clang.cpp:12:20: error: out-of-line definition of 'bar' does not
match any declaration in 'foo<true>'
auto foo<true>::bar (int i)
^~~
を与える、変更はありません:G ++コンパイルエラーを与える++打ち鳴らします。 auto
をint
に置き換えると、エラーは表示されなくなります。次のコードは、
template <bool>
struct foo
{
auto bar (int i)
{ return i; }
};
template <>
auto foo<true>::bar (int i)
{ return i; }
int main()
{
return 0;
}
両方のコンパイラで問題なくコンパイルので
template <typename T>
部分が重要である私の質問は明白です:右誰?
g ++またはclang ++?
g ++が正しく、これはclang ++のバグだと思うが、私は確認を求める。
p.s .:申し訳ありませんが、私の悪い英語です。
これはクランの問題だった –
... GCC 6.1と打ち鳴らす3.8を試してみてください。それは3.8で動作します:https://godbolt.org/g/JkCJ6l – refi64