4 ms·
Some intuition on #2: the biggest use-case for compound literals is to pass a one-off literal data structure into a function that takes a struct (or array) for
by naniwaduni 5y ago
Some intuition on #2: the biggest use-case for compound literals is to pass a one-off literal data structure into a function that takes a struct (or array) for input. But most functions you'd do this take arguments in that form because they don't want to pass each field or entry as a parameter, e.g. there might be lots or an unknown number of them, so they take a pointer. So for compound literals to be useful, you kind of have to be able to take an address of one.