boost_range_support_test.cpp 833 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2018-2019 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. #include <boost/core/lightweight_test.hpp>
  7. #include <boost/histogram/axis/integer.hpp>
  8. #include "throw_exception.hpp"
  9. #include <boost/histogram/histogram.hpp>
  10. #include <boost/histogram/make_histogram.hpp>
  11. #include <boost/range/adaptor/filtered.hpp>
  12. #include <boost/range/numeric.hpp>
  13. using namespace boost::histogram;
  14. using namespace boost::adaptors;
  15. int main() {
  16. auto h = make_histogram(axis::integer<>(1, 4));
  17. h(1, weight(1));
  18. h(2, weight(2));
  19. h(3, weight(3));
  20. h(4, weight(4));
  21. auto s1 = boost::accumulate(h | filtered([](double x) { return x > 2; }), 0.0);
  22. BOOST_TEST_EQ(s1, 7);
  23. return boost::report_errors();
  24. }