Programming in D page 295 - disable default constructor

Dukc ajieskola at gmail.com
Tue Feb 10 17:43:18 UTC 2026


On Tuesday, 10 February 2026 at 15:39:45 UTC, H. S. Teoh wrote:
> If you want complex default construction, polymorphic 
> behaviour, or by-reference semantics, consider using classes 
> instead.
>
>
> T

Or alternatively, design your struct to work as a reference to 
your actual data, not as the data itself. After all, this is 
pretty much how slices work. They essentially behave like a 
struct with a pointer and length value, with member functions and 
operator overloads to handle the actual data the slice is 
referring to.


More information about the Digitalmars-d-learn mailing list