Error: template instance does not match template declaration
Tejas
notrealemail at gmail.com
Wed Nov 17 12:20:44 UTC 2021
On Wednesday, 17 November 2021 at 12:19:05 UTC, Tejas wrote:
> On Wednesday, 17 November 2021 at 10:10:43 UTC, Vitalii wrote:
>> Hello! I am getting the following error:
>> ```
>> inst.d(8): Error: template instance `Worker!(Mode.Inspect)`
>> does not match template declaration `Worker(mode : Mode)
>> ```
>>
>> when compile next code:
>> ```
>> enum Mode { Inspect, Execute }
>>
>> class Worker(mode : Mode) {
>> this() {}
>> }
>>
>> void main() {
>> auto W = Worker!(Mode.Inspect)();
>> }
>> ```
>> Can anybody suggest to me what I do wrong?
>
> ```d
> enum Mode { Inspect, Execute }
>
> class Worker(Mode /*no need for template specialization :) */a)
> {
> this() {}
> }
>
> void main() {
> auto W = new/*Add new here, because this ais a class, not
> struct*/ Worker!(Mode.Inspect)();
> }
Sorry for typo, I meant "is", not "ais" :(
More information about the Digitalmars-d-learn
mailing list