I haven't checked the documentation of serialization, but I'm pretty sure that operator<<
for the types of boost::variant
needs to be either found by Argument Dependent Lookup or else be present in boost
namespace.
#include <iostream>
#include <vector>
#include <string>
#include <boost/serialization/variant.hpp>
namespace boost {
std::ostream& operator<<(std::ostream& out, const std::vector<int>& v) {
for(int i = 0; i < v.size(); ++i)
out << " " << v[i];
return out;
}
}
int main() {
boost::variant<int, std::string > a(3);
std::cout << a << '\n';
{
using namespace boost;
std::vector<int> b(3, 1);
std::cout << b << '\n';
}
boost::variant<int, std::vector<int> > c(3);
std::cout << c << '\n';
}
Output:
3
1 1 1
3