News for hackers. Stuff that matters.
Re:Std::visit is everything wrong with modern C++ (2017) by eMSF on Saturday December 05, 2020 @10:43AM (#25315337)
You don't see how variants improve readability over union+tag? Do you mean that you don't see a whole lot of difference below:

  std::variant<int, std::string> setting;
  setting = "foo"s;
  setting = 1;
Compared with something like:

  struct Setting {
    Setting() { XXX }
    ~Setting() { XXX }
    union {
      string str;
      int num;
    };
    enum Type { Str, Int, None };
    Type tag;
  };

  Setting setting;
  if (setting.tag != Setting::Str)
    new (&setting.str) std::string;
  setting.str = "foo";
  setting.tag = Setting::Str;

  if (setting.tag == Setting::Str)
    setting.str.~std::string();
  setting.str = 1;
  setting.tag = Setting::Int;
Re:Std::visit is everything wrong with modern C++ (2017) by socialdemocrat on Sunday December 06, 2020 @07:15AM (#25323017)
Looks like you are making things deliberately complicated. Here is an existing Variant type which existed long before modern C++ and which is easy to use: https://doc.qt.io/qt-5/qvariant.html