Alias template, partial specialization and the invalid parameter type void

Viewed 407

Consider the following code:

template<typename F>
struct S;

template<typename Ret, typename... Args>
struct S<Ret(Args...)> { };

template<typename... Args>
using Alias = S<void(Args...)>;

int main() {
    S<void(int)> s;
    Alias<int> alias;
}

It works fine, as expected and both the line involving S and the one involving Alias define under the hood the same type S<void(int)>.

Now, consider the following changes:

int main() {
    S<void(void)> s;  // this line compiles
    Alias<void> alias;  // this line does not
}

I expected it to compile, for reasons that are similar to the ones above mentioned.
It goes without saying that it doesn't compile because of the line involving Alias, instead I get the error:

In substitution of 'template using Alias = S [with Args = {void}]'

[...]

error: invalid parameter type 'void'

The question is pretty simple: what I missed here?

1 Answers
Related