sample.hpp 712 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 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. #ifndef BOOST_HISTOGRAM_SAMPLE_HPP
  7. #define BOOST_HISTOGRAM_SAMPLE_HPP
  8. #include <tuple>
  9. #include <utility>
  10. namespace boost {
  11. namespace histogram {
  12. template <class T>
  13. struct sample_type {
  14. T value;
  15. };
  16. /** Helper function to mark arguments as sample.
  17. @param ts arguments to be forwarded to the accumulator.
  18. */
  19. template <class... Ts>
  20. auto sample(Ts&&... ts) noexcept {
  21. return sample_type<std::tuple<Ts...>>{std::forward_as_tuple(std::forward<Ts>(ts)...)};
  22. }
  23. } // namespace histogram
  24. } // namespace boost
  25. #endif