samedi 30 mai 2015

Brace-or-equal initializer causing C2098 and C2059 in Visual Studio 2015 RC

The following, seemingly correct looking, code does not compile in Visual Studio 2015 RC, with errors like this:

test.cpp(6): error C2098: unexpected token after data member 'T'
  test.cpp(11): note: see reference to class template instantiation 'Foo<int>' being compiled
test.cpp(6): error C2059: syntax error: '>'

The code:

template <typename, typename> struct X {};

template <typename T>
struct Foo
{
    X<int, T> * p = new X<int, T>;
};

int main()
{
   Foo<int> f;
}

Why is this and how can I overcome this problem?

Aucun commentaire:

Enregistrer un commentaire