4 ms·
So the upside is that you can put it at the beginning of a function? Wild, bro
by ramon156 2y ago
So the upside is that you can put it at the beginning of a function? Wild, bro
- Joker_vD 2y agoYou can also use it in any template without any trickery unlike void, which I am willing to bet was the actual rationale.
- meibo 2y agoThe article describes that as the main advantage, showing std::variant as an example.
- Smaug123 2y agoHaving access to the unit type is useful; I use it maybe once every couple of months in F# even if we restrict solely to the use-case "instantiate a generic with the unit type to indicate that no data is held here". (Of course, since F# also doesn't have a `void` type - a truly non-constructible data type is indeed very rarely useful! - F# uses `unit` in many places where C++ and C# use `void`.)