4 ms·
`std::variant` is a clever piece of template hackery, but it doesn't come close to Rust enums. `std::variant` has no named variants, no pattern matching, no exh
by sapiogram 2y ago
`std::variant` is a clever piece of template hackery, but it doesn't come close to Rust enums. `std::variant` has no named variants, no pattern matching, no exhaustiveness checking. In Rust, it's not unusual to have an enum with dozens of variants, good luck doing that with std::variant.
I'm sure you could technically emulate all this in C++ is you keep throwing template metaprogramming at it, but at that point anything is a C++ subset and the statement loses all pratical meaning.
- pjmlp 2y agoPattern matching is on its way, one of the possible approaches being discussed, https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2688r1.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p26...
- leftyspook 2y agoComing right after profiles are done, probably?
- pjmlp 2y agoOne has nothing to with the other. That is the thing with committee driven languages, with multiple vendor implementations. Not everyone is on the same room voting for the same features, and not everyone is implementing the features in any specific order. By the way, I would rather have Safe C++ than profiles, but do not vote, so whatever.
- leftyspook 2y agoI'm not saying they are related, just saying that the committee committeing is going to take half a decade at least for both.
- pjmlp 2y agoWell, it is still going to be faster than WG14 ever doing anything useful improve the C's security model regarding arrays and strings. It has hardly moved since 1989, and annex K doesn't count, given its broken design. Anyway I am still mostly stuck with .NET Framework, Java 17, node 20 in many commercial deployments, so it isn't like everyone cares that much to update to latest, given existing business decisions. Those kind of industries don't care about programming language featurities anyway.
- steveklabnik 2y agoI understood your joke, but we just found out a few hours ago what happened in Hamburg, and while neither of these features made it yet, they're seemingly going in opposite directions: pattern matching had a poll in forwarding to the CWG, and it was mostly in favor, though enough were against it to not reach consensus profiles had a poll in forwarding to the CWG, and it was split down the line in terms of for/against. Given the previous votes on profiles being nearly unanimously for, I'm interested to see what people have to say about what went on.