0

VC++ 2017 reports C2760 error with this code:

template <typename x>
struct y
{
    static void z()
    {
        using def = typename x::d<0>;
    }
};

struct some
{
    template <int N> struct d;
};

// ... y<some> ...

Compiler output:

my.cpp(6): error C2760: syntax error: unexpected token '<', expected ';'
my.cpp(8): note: see reference to class template instantiation 'y<x>' being compiled

The question is how write def definition inside of y::z?

Raider
  • 197
  • 2
  • 10

1 Answers1

4
using def = typename x::template d<0>;

The compiler needs to be told that d is a template, otherwise < is interpreted as a less-than operator, not as the opening angle bracket.

Igor Tandetnik
  • 50,461
  • 4
  • 56
  • 85