0

I have this class definition (simplified here) which compiled fine with VS2008. In VS2017, I get a syntax error C2059 on the first angle bracket:

template < typename Function, typename Base, typename Specialiser = Base >
class FunctionTermBase : public Base
{
public:
    // typedef typename Function::result_type result_type;
    typedef typename Base term_type;
    typedef typename Specialiser specialiser;

protected:
    FunctionTermBase() { }

public:
    template <typename T>
    struct Specialise {
        typedef typename specialiser::Specialise<T>::type type;
    };
};

I'd appreciate if someone could tell me what is wrong with this code?

APerson
  • 8,140
  • 8
  • 35
  • 49
Sam Dahan
  • 871
  • 1
  • 8
  • 20
  • ***I get a syntax error C2059 on the first angle bracket:*** It may help to add the text of the exact error message to your question. – drescherjm May 30 '17 at 20:16

1 Answers1

3

You must use the template keyword to indicate that the following dependent name also has template arguments. Additionally, typename is not required in your typedefs since the identifiers are already known to be types (they are template arguments).

template < typename Function, typename Base, typename Specialiser = Base >
class FunctionTermBase : public Base
{
public:
    // typedef typename Function::result_type result_type;
    typedef Base term_type;
    typedef Specialiser specialiser;

protected:
    FunctionTermBase() { }

public:
    template <typename T>
    struct Specialise {
        typedef typename specialiser::template Specialise<T>::type type;
        //          Add template here ^^^^^^^^
    };
};
François Andrieux
  • 28,148
  • 6
  • 56
  • 87