Template instance does not match template declaration
Sergey
kornburn at yandex.ru
Fri Aug 15 12:20:16 UTC 2025
On Friday, 15 August 2025 at 12:02:19 UTC, Marc wrote:
> Hello,
> I'm trying to declare a templated member function that takes a
> value of size_t N. A simple example to reproduce what Im trying
> to do is the following:
>
> ```d
> import std.stdio;
> void getCol(N: size_t)() {
> return N;
> }
>
> void main() {
> // Call
> writeln(getCol!0());
> }
> ```
> I get the following error: `Error: template instance `getCol!0`
> does not match template declaration `getCol(N : ulong)()`
> writeln(getCol!0());
> ^
> Error dmd failed with exit code 1.`
>
> Can anyone please help me getting it to work?
D doesn't use ":" for types
```d
import std;
size_t getCol(size_t N)() {
return N;
}
void main() {
// Call
writeln(getCol!0());
}
```
More information about the Digitalmars-d-learn
mailing list