2016-08-27 6 views
5

私は問題を再現するために生成することができました最小限のコードは:コードをコンパイルしているときにエラーを以下非タイプのパラメータ・パックで内部クラス・テンプレートを定義するために非タイプのパラメータ・パックを拡張することはできますか?

template <int> 
struct Tag { }; 

Tag<0> w; 

template <int... Is> 
struct Outer { 
    template <Tag<Is> &...> 
    struct Inner { 
    }; 
}; 

int main() { 
    Outer<0>::Inner<w> f; 
} 

グラム++(バージョン6.1.1 20160511)の出会い:

pp.cc: In function ‘int main()’: 
pp.cc:14:21: internal compiler error: unexpected expression ‘Is’ of kind template_parm_index 
    Outer<0>::Inner<w> f; 

そして、長く退屈なスタックトレースを生成します。バージョン3.6.0のclang ++は、コードのコンパイルに問題はないようです。型テンプレートパラメータを持つ同じコードは、両方のコンパイラでうまくコンパイル:

template <class> 
struct Tag { }; 

Tag<int> w; 

template <class... Ts> 
struct Outer { 
    template <Tag<Ts> &...> 
    struct Inner { 
    }; 
}; 

int main() { 
    Outer<int>::Inner<w> f; 
} 
ので

それをg ++のバグであるか、私はクラステンプレートパラメータの展開には適用されない非型可変長テンプレートパラメータの展開に関する重要な何かが欠けています? GCCのための

+11

「内部コンパイラエラー」は明確にGCCのバグを意味し、関係なく、これは有効なCである++か。 – kennytm

+2

ありがとう!私はそれを知らなかった... –

+0

構文 'template &...>構造体内の{};はどういう意味ですか? – Zereges

答えて

0

(未解答誰かが興味があるかもしれません)

可能な比較的簡単な回避策:

template <int> 
struct Tag { }; 

Tag<0> w; 

template <class... Ts> 
struct OuterParent { 
    template <Ts&...> 
    struct Inner { 
    }; 
}; 

template <int... Is> 
struct Outer:OuterParent<Tag<Is>...> { 
}; 

int main() { 
    Outer<0>::Inner<w> f; 
} 
関連する問題