Search⌘ K

Using Templates in Multi-Dimensional Operator Overloading

Explore how to apply D's template system to overload operators for multi-dimensional collections. Understand opDollar, opSlice, and opIndex templates to manage element access, ranges, and slicing across dimensions, enabling flexible and efficient code.

We'll cover the following...

Multi- dimensional operator overloading

In the operator overloading chapter, you saw that opDollar, opIndex, and opSlice are for element indexing and slicing. When overloaded for single-dimensional collections, these operators have the following responsibilities:

  • opDollar: Returns the number of elements of the collection

  • opSlice: Returns an object that ...