Boost logo

Boost Users :

Subject: [Boost-users] [variant] Possible regression from 1.55 to 1.58
From: Mario Lang (mlang_at_[hidden])
Date: 2015-08-11 05:46:25


Hi.

I just upgraded my Boost from 1.55 to 1.58. My project doesn't build
anymore, it fails on the following pattern, which used to work with 1.55:

---<snip>---
#include <algorithm>
#include <boost/variant.hpp>
#include <string>
#include <iostream>
#include <vector>

struct visitor : boost::static_visitor<std::ostream &> {
  result_type operator() (int) { return std::cout; }
  result_type operator() (std::string) const { return std::cout; }
};

int main() {
  std::vector< boost::variant<int, std::string> > v;
  visitor vis;
  foreach(v.begin(), v.end(), boost::apply_visitor(vis));
  return 0;
}
---<snip>---

The example is a bit silly, since foreach discards the return value of
apply_visitor anyway. So my solution was to change the visitor to
define result_type as void. This works. However, I am wondering why
delayed_visitor does no longer work in this situation? Is it because I
am trying to return a reference?

-- 
CYa,
  ⡍⠁⠗⠊⠕

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net