ostream.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_ACCUMULATORS_OSTREAM_HPP
  7. #define BOOST_HISTOGRAM_ACCUMULATORS_OSTREAM_HPP
  8. #include <boost/histogram/fwd.hpp>
  9. #include <iosfwd>
  10. #ifndef BOOST_HISTOGRAM_DOXYGEN_INVOKED
  11. namespace boost {
  12. namespace histogram {
  13. namespace accumulators {
  14. template <typename CharT, typename Traits, typename W>
  15. std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os,
  16. const sum<W>& x) {
  17. os << "sum(" << x.large() << " + " << x.small() << ")";
  18. return os;
  19. }
  20. template <typename CharT, typename Traits, typename W>
  21. std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os,
  22. const weighted_sum<W>& x) {
  23. os << "weighted_sum(" << x.value() << ", " << x.variance() << ")";
  24. return os;
  25. }
  26. template <typename CharT, typename Traits, typename W>
  27. std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os,
  28. const mean<W>& x) {
  29. os << "mean(" << x.count() << ", " << x.value() << ", " << x.variance() << ")";
  30. return os;
  31. }
  32. template <typename CharT, typename Traits, typename W>
  33. std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os,
  34. const weighted_mean<W>& x) {
  35. os << "weighted_mean(" << x.sum_of_weights() << ", " << x.value() << ", "
  36. << x.variance() << ")";
  37. return os;
  38. }
  39. } // namespace accumulators
  40. } // namespace histogram
  41. } // namespace boost
  42. #endif // BOOST_HISTOGRAM_DOXYGEN_INVOKED
  43. #endif