News for hackers. Stuff that matters.
Re:When to use generics by closeparen on Wednesday April 13, 2022 @04:05AM (#31012231)
If you have e.g. a *string you can't populate it with &"hello world." You have to first assign the string to a variable and then take the address of that variable. This comes up very often in tests and is super inconvenient. Many people write TypeNamePtr functions so that you can call e.g. StringPtr("hello world") to express it in one line and without creating any names. Without generics you had to do this individually for every type.

There are no comments on this comment yet.