On Friday, 15 August 2025 at 12:20:16 UTC, Sergey wrote:
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());
}
```

Thanks for your reply. It solved my problem.

Reply via email to