How to call a templated overload of opIndex

Marc mailnawman at gmail.com
Fri Aug 15 17:38:53 UTC 2025


Hello,
In my typed data frames I've this type of code. It works for 
default value (float) but I can't call `opIndex!double[i, j]` or 
`opIndex!string[i,j]`. It just doesn't work and I get the error 
`is not a template declaration, it is a variable`.

```d
// Overload [i, j]
ref T opIndex(T = float)(size_t i, size_t j) const {
    alias SliceType = Slice!(T*);
    // colValues is of type void*[], i cast it to a slice type and 
get
    // the value at index i (row index)
    auto values = cast(SliceType*) colValues[j];
    return (*values)[i];
}
```

Any help would be really appreciated.


More information about the Digitalmars-d-learn mailing list