ostream.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2015-2017 Hans Dembinski
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_HISTOGRAM_OSTREAM_HPP
  7. #define BOOST_HISTOGRAM_OSTREAM_HPP
  8. #include <boost/histogram/accumulators/ostream.hpp>
  9. #include <boost/histogram/axis/ostream.hpp>
  10. #include <boost/histogram/fwd.hpp>
  11. #include <iosfwd>
  12. #ifndef BOOST_HISTOGRAM_DOXYGEN_INVOKED
  13. namespace boost {
  14. namespace histogram {
  15. template <typename CharT, typename Traits, typename A, typename S>
  16. std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os,
  17. const histogram<A, S>& h) {
  18. os << "histogram(";
  19. unsigned n = 0;
  20. h.for_each_axis([&](const auto& a) {
  21. if (h.rank() > 1) os << "\n ";
  22. os << a;
  23. if (++n < h.rank()) os << ",";
  24. });
  25. os << (h.rank() > 1 ? "\n)" : ")");
  26. return os;
  27. }
  28. } // namespace histogram
  29. } // namespace boost
  30. #endif // BOOST_HISTOGRAM_DOXYGEN_INVOKED
  31. #endif