いさぽん部屋(isapon.com)

ゲーム系プログラマによる特に方針のないブログ。技術系とカレー、ラーメンネタ多めだったはずが、最近はダイエットネタ多め。

clang/gcc bugs? 可変長テンプレートの特殊化を伴ったキャストがうまくいかない。

clang/gcc) 可変長テンプレートのクラスを継承しているとき、暗黙的なキャストに失敗する。
VisualC++) コンパイルが通り思惑通りの結果を取得できる。


clang/gcc) Implicit casting fails when inheriting variable-length template class.
VisualC++) can be compiled and get the expected results.


誰かclangのチームにレポートを送ってくれ(自分でするのは面倒なのでやりたくない)。
Please send a report to some clang team.

// prototype. not use.
template<class...>
struct  lasttype;


// one type specialize.
template<class First>
struct  lasttype<First>
{
    using   type    = First;
};


// not ones.
template<class First, class... Other>
struct  lasttype<First, Other...>
        : lasttype<Other...>          // Problem.
{
};



template<class First, class Second, class... Other>
void func(lasttype<First, Second, Other...>&)             // Error. Can't implicit cast.
{
}



struct  bar
        : lasttype<char, short, int>     // I want implicit cast to lasttype<F, S, O...>
{
};


int main(int _argc, char** _args)
{
    bar t;
    func(t);
    return  0;
}