News for hackers. Stuff that matters.
Re:Switching from C++ to Rust by MathMonkeyMan on Monday March 13, 2023 @09:53PM (#35146295)
Until very recently, all of the C++ code I wrote was in the 1998 style or in the 2014 style.

Since 2017, there is std::variant, which is a sum type template that _technically_ allows for language-level exhaustiveness checking via std::visit. It's not pretty, but it gets you there without requiring compiler support.

Rust's version looks way better.

Re:Switching from C++ to Rust by otabdeveloper4 on Tuesday March 14, 2023 @01:54AM (#35147887)
boost::variant has been around forever.

Most modern C++ codebases do compile-time polymorphism via templates, though. std::variant is a niche use for things like serialization, when you need to make type choices at runtime.

Re:Switching from C++ to Rust by chippiewill on Tuesday March 14, 2023 @08:27AM (#35150381)
I was really excited for `std::variant`, when I actually got it I was seriously disappointed.

It's just a pain to use because of how much template magic is used.