0

次のコード(MWE) は、gcc 4.5.3 以降ではコンパイルされますが、VS 2008 および 2010 ではコンパイルされません。既知の VS コンパイラのバグですか? func()また、インラインで定義する以外に回避策はありますか。

enum DeviceState{ ON , OFF , BUSY , WAITING };

template<typename T>
struct Foo
{
    typedef DeviceState State;

    template<State S>
    void func();     // no error if implementation is inline
};

template<typename T>
template<typename Foo<T>::State>
void Foo<T>::func()
{
}

int main()
{
    Foo<Bar> f;
    f.func<ON>();
}

VS エラー メッセージ

error C2244: 'Foo<T>::func' : unable to match function definition to an existing declaration
        definition
        'void Foo<T>::func(void)'
        existing declarations
        'void Foo<T>::func(void)'

編集: これは、私が報告した以前の問題の別のバージョンのようです。

4

0 に答える 0