3 ms·
The downside is now all types must dogmatically have a nullary constructor. The Default typeclass (or trait) as seen in Haskell and Rust, is a far better desig
by thowruasdf 2y ago
The downside is now all types must dogmatically have a nullary constructor.
The Default typeclass (or trait) as seen in Haskell and Rust, is a far better design, as this makes the feature opt-in for data types that truly support them.
- kccqzy 2y agoDon't even need to go that far. In C++ it is common to delete the default constructor anyways. So that achieves the opt-in.
- dieortin 2y agoHaving to delete the default constructor means it’s opt-out, not opt-in
- kccqzy 2y agoI don't think you really know what a real-life C++ code base looks like. Deleting the default constructor often happens implicitly with no syntax needed. This often happens when you define a custom constructor or when its member doesn't have a default constructor.