How to make a generic function to take a class or struct by reference?
Steven Schveighoffer
schveiguy at gmail.com
Sun Mar 27 18:12:29 UTC 2022
On 3/27/22 12:27 PM, JN wrote:
> int* getX(T)(T t)
> {
> return &t.x;
> }
Remove this one. It's a bad idea. It probably won't compile, but if it
does, you will be using corrupted memory.
-Steve
More information about the Digitalmars-d-learn
mailing list