Void is surprisingly useful.
Void is surprisingly useful.
Posted Sep 9, 2026 12:50 UTC (Wed) by tux3 (subscriber, #101245)In reply to: Void is surprisingly useful. by ralfj
Parent article: Stabilizing Rust's never type
Also note that C's rules around void are too irregular to make it work as a unit type. You can't declare a void variable. It's not really an empty type or a unit type, it's a secret third thing.
In C++ this forces templates to special-case void. There was a proposal to make void more regular, but that wasn't going to happen without breakage, so C++ added std::monostate instead, which is actually intended as a unit type.
The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:
Note: you can avoid this step in the future by logging into your LWN account.
