0

The following code (also on ideone):

// A type templated for different function call signatures.
template <typename Signature> class Used;
template <typename T_Ret, typename ...T_Args>
class Used<T_Ret(T_Args...)> {
public:
    // A static method for a specific type.
    template <typename T>
    static void specific() { }
};

// Some class using the above.
template <typename T>
class User {
public:
    // A method that must call the specific function of used.
    template <typename T_Ret, typename ...T_Args>
    void method() {
        using It = Used<T_Ret(T_Args...)>;
        using Me = T;
        // error: expected primary-expression before '>' token
        It::specific<Me>();
    }
};

int main() {
    User<int> user;
    user.method<void, int>();
}

gives the following error (at least using GCC):

test.cpp: In member function 'void User<T>::method()':
test.cpp:20:18: error: expected primary-expression before '>' token
   It::specific<Me>();
                  ^

And I have no idea why... The error does not occur if the template parameters are removed from the Used class.

Am I doing something wrong (i.e., missing a template or typename keyword somewhere)? Is this a bug in GCC? Is there a workaround?

zennehoy
  • 6,405
  • 28
  • 55

1 Answers1

1

Because specific is a dependent name you need a template keyword:

It::template specific<Me>();
//--^^^^^^^^
John Cena
  • 147
  • 1
  • 6
  • Thank you! Now that I know what the proper solution is I'll take (another) look at the link from @sleeptightpupper comment to understand why. Thanks! – zennehoy Jun 06 '16 at 13:49