I have a base class for a generic callable that I'm marking __declspec(novtable)
:
template<class F> struct callable;
template<class R, class... T>
struct __declspec(novtable) callable<R(T...)>
{ virtual R operator()(T...) volatile { return R(); } };
but somehow this does not error like it's supposed to:
int main()
{
auto temp = new callable<void()>();
temp->operator()();
}
Why is novtable
not working?
Apparently Visual C++ looks at __declspec(novtable)
on the template, not its specializations!
This doesn't make sense to me (is it a bug?), but the "solution" is to write this:
template<class F> struct __declspec(novtable) callable;