News for hackers. Stuff that matters.
Re:Programming Your Own Language in C++ by wcrichton on Monday August 08, 2016 @01:03AM (#12245601)
They solve the memory issue, although they are inconvenient to use vs. pattern matching and aren't type safe. Additionally, I've had no luck using classes (e.g. string) inside of unions because the compiler reasonably complains about initializers. I believe this is somewhat solved with boost::variant (and that's also getting put into C++17, iirc), but ideally it would be a part of the type system.
Re:Programming Your Own Language in C++ by wolfgke on Monday August 08, 2016 @06:40AM (#12246682)
Replace the type (e.g. std::string) by the pointer type (e.g. std::string*) in the union.