News for hackers. Stuff that matters.
Re:Std::visit is everything wrong with modern C++ by tlb on Thursday September 14, 2017 @03:46PM (#15251859)
You can use variants just fine without a visitor. Like,

  std::variant<string, int, bool> v;
  ...
  if (auto pstr = std::get_if<string>(&v)) {
    cout << *pstr << endl;
  }
  else if (auto pint = std::get_if<int>(&v)) {
    cout << *pint << endl;
  }
  else if (auto pbool = std::get_if<bool>(&v)) {
    cout << *pbool << endl;
  }
  else {
    count << "null" << endl;
  }
 
which is not much worse than the pattern matching syntax.
Re:Std::visit is everything wrong with modern C++ by ezyang on Thursday September 14, 2017 @03:51PM (#15251899)
You don't get exhaustiveness checking, which is the killer feature of variants.
Re:Std::visit is everything wrong with modern C++ by joe_loser on Thursday September 14, 2017 @09:54PM (#15253992)
Yeah, plus the if branches are runtime-checks instead of the if-constexpr approach
Re:Std::visit is everything wrong with modern C++ by gpderetta on Friday September 15, 2017 @05:02AM (#15255658)
There is about the same amount of runtime checks. In the auto-lambda+constexpr case the switch/if-cascade is inside visit and it is required to dispatch the correct type to the visitor.