Boost-1.70 released, new library boost::histogram

Hi Eliott,

the default storage of a boost::histogram in C++ is the unlimited_storage, which is a complex piece of technology and cannot be easily serialized automatically. boost::histogram fully supports serialization with boost::serialization and possibly other other compatible serialization libraries, like cereal, but that is not tested.

As a workaround, you could try to change the storage of the histogram from boost::histogram::unlimited_storage<std::__1::allocator<char> > to std::vector<double>. Perhaps it works then.

If using the unlimited storage is important to you, I don’t know an easy way forward. You can look into the serialization code of that class for inspiration on how to do this with ROOT streamers (I am not an expert on ROOT streamers, only on boost::serialization).

  template <class Archive>
  void serialize(Archive& ar, unsigned /* version */) {
    if (Archive::is_loading::value) {
      buffer_type tmp(buffer_.alloc);
      std::size_t size;
      ar& make_nvp("type", tmp.type);
      ar& make_nvp("size", size);
      tmp.visit([this, size](auto* tp) {
        assert(tp == nullptr);
        using T = std::decay_t<decltype(*tp)>;
        buffer_.template make<T>(size);
      });
    } else {
      ar& make_nvp("type", buffer_.type);
      ar& make_nvp("size", buffer_.size);
    }
    buffer_.visit([this, &ar](auto* tp) {
      auto w = detail::make_array_wrapper(tp, this->buffer_.size);
      ar& make_nvp("buffer", w);
    });
  }