Reputation: 23789
I'm attempting to compile the following with VS2017:
template <typename R, typename ...Args>
struct Logger3<R(Args...)>
{
std::function<R(Args...)> func;
string name;
Logger3(std::function<R(Args...)> func, const string& name)
: func{func}, name{name}
{
}
R operator() (Args ...args)
{
cout << "Entering " << name << endl;
R result = func(args...);
cout << "Exiting " << name << endl;
return result;
}
};
double add(double a, double b)
{
cout << a << " + " << b << " = " << (a+b) << endl;
return a+b;
}
template <typename R, typename... Args>
auto make_logger3(R (*func)(Args...), const string& name)
{
return Logger3<R(Args...)>(
std::function<R(Args...)>(func),
name
);
};
and I'm getting error C2988: unrecognizable template declaration/definition
on the very first line. What am I doing wrong?
Upvotes: 0
Views: 56
Reputation: 217388
You should have template <typename> struct Logger3;
before your specialization.
Upvotes: 2