So, I reduce down some code I have to this :
#include <iostream>
#include <functional>
using namespace std;
struct Test {
template <class T>
void operator()() {
cout << typeid(T).name() << endl;
}
template <class T>
void f() {
cout << typeid(T).name() << endl;
}
};
template <typename S, typename T, typename T1>
mem_fun_ref_t<S, T> make_mem_fun_ref()
{
return mem_fun_ref(&T::template operator()<T1>); //A
//return mem_fun_ref(&T::template f<T1> ); //B
}
int main(int argc, char *argv[]) {
Test t;
make_mem_fun_ref<void, Test, int>()(t);
}
This compiles just fine under gcc, but VS2013 complains about : "error C2902: 'operator' : unexpected token following 'template', identifier expected".
Now, if I comment line A and use line B, VS does not complain anymore.
Is that a bug related to the interpretation of the template keyword with the operator() ? Should I change the syntax or enable some magic flag/pragma to compile line A ?
BTW: I need to have a mem_fun_ref_t that refers to a templated member operator() of some functor. Before anyone suggests it, I can't use any C++11 or Boost code.
Thanks