4 ms·
The feature I like here is an old Common Lisp feature: accepting as many returned values as you’d like. C/C++ allows you to accept 0 returned values without sp
by gumby 9y ago
The feature I like here is an old Common Lisp feature: accepting as many returned values as you’d like. C/C++ allows you to accept 0 returned values without special syntax, but in all other cases you have to be careful. Whereas in CL you can return as many values as you like and the caller can accept as few of them as it likes with no extra overhead.
In c++17 you can sort of do that but you still have to unpack the whole tuple (and the caller has to make one instead of simply doing ‘return a, b, c;’ to return three values. I understand why the C++ committee didn’t make this change (it would break valid programs, though there are likely few to none of them).
- fooker 9y agoHaving to write : return {1, "42", '2'}; seems like a fair trade-off to me. Btw, this is already implemented from c++11.