Clang 3.2のバグかC++ 03の違反かどうかは不明ですが、テンプレートクラスのテンプレートコンストラクタの明示的なインスタンス化は失敗しますが、テンプレート化されたテンプレートクラスのメンバ関数は成功します。例えばテンプレートクラスのテンプレートコンストラクタの明示的なインスタンス化
、と問題なく次のコンパイルの両方打ち鳴らす++およびg ++:++ gの警告なしに次のコンパイル一方
template<typename T>
class Foo
{
public:
template<typename S>
void Bar(const Foo<S>& foo)
{ }
};
template class Foo<int>;
template class Foo<float>;
template void Foo<int>::Bar(const Foo<int>& foo);
template void Foo<int>::Bar(const Foo<float>& foo);
template void Foo<float>::Bar(const Foo<int>& foo);
template void Foo<float>::Bar(const Foo<float>& foo);
しかし++打ち鳴らすで失敗:特に
template<typename T>
class Foo
{
public:
template<typename S>
Foo(const Foo<S>& foo)
{ }
};
template class Foo<int>;
template class Foo<float>;
template Foo<int>::Foo(const Foo<int>& foo);
template Foo<int>::Foo(const Foo<float>& foo);
template Foo<float>::Foo(const Foo<int>& foo);
template Foo<float>::Foo(const Foo<float>& foo);
、I次の形式の2つのエラーメッセージを参照してください。
TemplateMember.cpp:12:20: error: explicit instantiation refers to member
function 'Foo<int>::Foo' that is not an instantiation
template Foo<int>::Foo(const Foo<int>& foo);
^
TemplateMember.cpp:9:16: note: explicit instantiation refers here
template class Foo<int>;
^
これは違反ですか標準のバグかclang ++のバグ?
有効なC++ 03のように見えます。おそらくClangのバグです。++ –