0

The following bit of code (a MWE) compiles in gcc 4.5.3 and above but does not compile in VS 2008 and 2010. Is it a known VS compiler bug? And are there any workarounds, other than to define func() inline.

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 message

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)'

Edit: This appears to be another version of an earlier issue I reported.

Community
  • 1
  • 1
Olumide
  • 5,397
  • 10
  • 55
  • 104

0 Answers0