On Tuesday, 8 December 2020 at 20:11:40 UTC, Nathan S. wrote:
The following code fails to compile. Is this a compiler error or if not what is wrong with the code?

What is wrong is that partial specialization is not correct.
The correct partial specialization is:

---
struct Template2(T)
{
    enum tString = T.stringof;
    static if (is(T == class))
        enum tLinkage = __traits(getLinkage, T);
}

struct Template1(Param1, Param2 = Template2!Param1) {}

alias AliasTemplate1S(SecondParam) = Template1!(S,SecondParam);
//                    ^here

class S
{
    Template1!int x;
}
---

Now that being said, the compiler could complain about the incorrect partial spec instead of falling in the nonsensical error message.

There is a gap because the second template param looks optional so you dont put it the partial specialization but it is still required.

Anyway. This case is either a "bad diagnostic" or an "enhancement" request.
Or should be specified.

Reply via email to